mirror of
https://github.com/php/doc-ja.git
synced 2026-03-24 15:12:22 +01:00
176 lines
5.7 KiB
XML
176 lines
5.7 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: c2eca73ef79ebe78cebb34053e41b565af504c4f Maintainer: hirokawa Status: ready -->
|
|
<!-- CREDITS: takagi,mumumu -->
|
|
<refentry xml:id="function.pg-delete" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>pg_delete</refname>
|
|
<refpurpose>
|
|
レコードを削除する
|
|
</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type class="union"><type>string</type><type>bool</type></type><methodname>pg_delete</methodname>
|
|
<methodparam><type>PgSql\Connection</type><parameter>connection</parameter></methodparam>
|
|
<methodparam><type>string</type><parameter>table_name</parameter></methodparam>
|
|
<methodparam><type>array</type><parameter>conditions</parameter></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>flags</parameter><initializer><constant>PGSQL_DML_EXEC</constant></initializer></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>pg_delete</function> は、<parameter>conditions</parameter>
|
|
で指定したキーと値を用いてテーブルからレコードを削除します。
|
|
</para>
|
|
<para>
|
|
<parameter>flags</parameter> が指定された場合、指定したオプションを
|
|
つけて <function>pg_convert</function> が <parameter>conditions</parameter>
|
|
に適用されます。
|
|
</para>
|
|
<para>
|
|
デフォルトでは、
|
|
<function>pg_delete</function> は生の値を渡します。
|
|
値はエスケープするか、
|
|
<constant>PGSQL_DML_ESCAPE</constant> オプションを指定しなければいけません。
|
|
<constant>PGSQL_DML_ESCAPE</constant> はパラメータや識別子をクォートし、
|
|
エスケープします。
|
|
よって、テーブル/カラム名は大文字小文字を区別します。
|
|
</para>
|
|
<para>
|
|
エスケープやプリペアドクエリであっても、
|
|
LIKE, JSON, Array, Regex などのクエリを守れない可能性があることに注意してください。
|
|
これらのパラメータはコンテクストに応じて処理されるべきです。
|
|
たとえば、値をエスケープ/検証する処理を行うことなどです。
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>connection</parameter></term>
|
|
<listitem>
|
|
&pgsql.parameter.connection;
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>table_name</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
行を削除するテーブルの名前。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>conditions</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
そのキーが <parameter>table_name</parameter> テーブルのフィールド名、
|
|
値が削除したいフィールドの値となっている配列。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>flags</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
<constant>PGSQL_CONV_FORCE_NULL</constant>、
|
|
<constant>PGSQL_DML_NO_CONV</constant>、
|
|
<constant>PGSQL_DML_ESCAPE</constant>、
|
|
<constant>PGSQL_DML_EXEC</constant>、
|
|
<constant>PGSQL_DML_ASYNC</constant> あるいは
|
|
<constant>PGSQL_DML_STRING</constant> を組み合わせた数。
|
|
<parameter>flags</parameter> に <constant>PGSQL_DML_STRING</constant>
|
|
が含まれている場合、クエリ文字列が返されます。
|
|
<constant>PGSQL_DML_NO_CONV</constant> あるいは <constant>PGSQL_DML_ESCAPE</constant>
|
|
が設定されている場合は、内部的に <function>pg_convert</function> を呼びません。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
&return.success;
|
|
<parameter>flags</parameter> で <constant>PGSQL_DML_STRING</constant>
|
|
が渡された場合は文字列を返します。
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="changelog">
|
|
&reftitle.changelog;
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
&pgsql.changelog.connection-object;
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title><function>pg_delete</function> の例</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$db = pg_connect('dbname=foo');
|
|
// これは少しだけ安全です。なぜなら、全ての値がエスケープされるからです。
|
|
// しかし、PostgreSQL は JSON/Array をサポートしています。これらの型に
|
|
// ついてはエスケープされたクエリや、プリペアドクエリでも安全ではありません。
|
|
$res = pg_delete($db, 'post_log', $_POST, PG_DML_ESCAPE);
|
|
if ($res) {
|
|
echo "POST data is deleted: $res\n";
|
|
} else {
|
|
echo "User must have sent wrong inputs\n";
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>pg_convert</function></member>
|
|
</simplelist>
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|