mirror of
https://github.com/php/doc-ja.git
synced 2026-03-24 07:02:08 +01:00
184 lines
5.4 KiB
XML
184 lines
5.4 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 39bb8a868935a56cfce438b0169e13c02c93211c Maintainer: hirokawa Status: ready -->
|
|
<!-- CREDITS: takagi,mumumu -->
|
|
<refentry xml:id="function.pg-convert" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>pg_convert</refname>
|
|
<refpurpose>
|
|
連想配列の値を、SQL 文として実行可能な形式に変換する
|
|
</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type class="union"><type>array</type><type>false</type></type><methodname>pg_convert</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 choice="opt"><type>int</type><parameter>flags</parameter><initializer>0</initializer></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>pg_convert</function> は、<parameter>values</parameter>
|
|
の中の値をチェックし、SQL 文の中で使用可能な形式に変換します。
|
|
少なくとも <parameter>values</parameter> の要素数以上のカラムを持つ
|
|
テーブル <parameter>table_name</parameter> が存在することが前提条件と
|
|
なります。<parameter>values</parameter> の要素名が
|
|
<parameter>table_name</parameter> のフィールド名と一致し、また
|
|
要素に対応する値はフィールドのデータ型と互換性がなければなりません。
|
|
成功した場合に変換後の値の配列、それ以外の場合に &false; を返します。
|
|
</para>
|
|
<note>
|
|
<para>
|
|
この関数は、boolean 値も受付けることができ、
|
|
PostgreSQL の boolean 型に変換します。
|
|
boolean 値の文字列表現にも対応しています。
|
|
&null; は、PostgreSQL の NULL に変換します。
|
|
</para>
|
|
</note>
|
|
&warn.experimental.func;
|
|
</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>
|
|
変換されるデータ。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>flags</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
<constant>PGSQL_CONV_IGNORE_DEFAULT</constant>,
|
|
<constant>PGSQL_CONV_FORCE_NULL</constant> あるいは
|
|
<constant>PGSQL_CONV_IGNORE_NOT_NULL</constant> の組み合わせ。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
変換された値の配列を返します。
|
|
&return.falseforfailure;
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="errors">
|
|
&reftitle.errors;
|
|
<para>
|
|
フィールドの値や型が PostgreSQL の型と一致しない場合、
|
|
<classname>ValueError</classname> または <classname>TypeError</classname>
|
|
がスローされます。
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="changelog">
|
|
&reftitle.changelog;
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>8.3.0</entry>
|
|
<entry>
|
|
フィールドの値や型が PostgreSQL の型と一致しない場合、
|
|
<classname>ValueError</classname> または <classname>TypeError</classname>
|
|
がスローされるようになりました。
|
|
これより前のバージョンでは、
|
|
<constant>E_WARNING</constant> が発生していました。
|
|
</entry>
|
|
</row>
|
|
&pgsql.changelog.connection-object;
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title><function>pg_convert</function> の例</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$dbconn = pg_connect('dbname=foo');
|
|
|
|
$tmp = array(
|
|
'author' => 'Joe Thackery',
|
|
'year' => 2005,
|
|
'title' => 'My Life, by Joe Thackery'
|
|
);
|
|
|
|
$vals = pg_convert($dbconn, 'authors', $tmp);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>pg_meta_data</function></member>
|
|
<member><function>pg_insert</function></member>
|
|
<member><function>pg_select</function></member>
|
|
<member><function>pg_update</function></member>
|
|
<member><function>pg_delete</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
|
|
-->
|