mirror of
https://github.com/php/doc-ja.git
synced 2026-03-24 15:12:22 +01:00
191 lines
6.3 KiB
XML
191 lines
6.3 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- splitted from ./en/functions/pgsql.xml, last change in rev 1.80 -->
|
|
<!-- EN-Revision: c2eca73ef79ebe78cebb34053e41b565af504c4f Maintainer: hirokawa Status: ready -->
|
|
<!-- CREDITS: takagi,mumumu -->
|
|
<refentry xml:id="function.pg-update" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>pg_update</refname>
|
|
<refpurpose>
|
|
テーブルを更新する
|
|
</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type class="union"><type>string</type><type>bool</type></type><methodname>pg_update</methodname>
|
|
<methodparam><type>PgSql\Connection</type><parameter>connection</parameter></methodparam>
|
|
<methodparam><type>string</type><parameter>table_name</parameter></methodparam>
|
|
<methodparam><type>array</type><parameter>values</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_update</function> は、
|
|
<parameter>conditions</parameter> にマッチするレコードを
|
|
<parameter>values</parameter> に更新します。
|
|
</para>
|
|
<para>
|
|
<parameter>flags</parameter> が指定された場合、指定したオプションとともに
|
|
<function>pg_convert</function> が <parameter>data</parameter>
|
|
に適用されます。
|
|
</para>
|
|
<para>
|
|
デフォルトでは、
|
|
<function>pg_update</function> は生の値を渡します。
|
|
値はエスケープするか、
|
|
<parameter>flags</parameter> に <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>values</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
テーブル <parameter>table_name</parameter> のフィールド名をキーに、
|
|
そしてマッチした対象を更新するデータを値にもつ配列。
|
|
</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_update</function> の例</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$db = pg_connect('dbname=foo');
|
|
$data = array('field1'=>'AA', 'field2'=>'BB');
|
|
|
|
// これは少しだけ安全です。なぜなら、全ての値がエスケープされるからです。
|
|
// しかし、PostgreSQL は JSON/Array をサポートしています。これらの型に
|
|
// ついてはエスケープされたクエリや、プリペアドクエリでも安全ではありません。
|
|
$res = pg_update($db, 'post_log', $_POST, $data);
|
|
if ($res) {
|
|
echo "データが更新されました: $res\n";
|
|
} else {
|
|
echo "ユーザーが誤った入力を送信しました。\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
|
|
-->
|