reference/pgsql/functions/pg-convert.xml
39bb8a868935a56cfce438b0169e13c02c93211c
...
...
@@ -1,46 +1,40 @@
1
1
<?xml version="1.0" encoding="utf-8"?>
2
2
<!-- $Revision$ -->
3
3
<!-- splitted from ./en/functions/pgsql.xml, last change in rev 1.80 -->
4
-
<refentry xml:id='function.pg-convert' xmlns="http://docbook.org/ns/docbook">
4
+
<refentry xml:id="function.pg-convert" xmlns="http://docbook.org/ns/docbook">
5
5
<refnamediv>
6
6
<refname>pg_convert</refname>
7
7
<refpurpose>
8
-
Convert associative array values into suitable for SQL statement
8
+
Convert associative array values into forms suitable for SQL statements
9
9
</refpurpose>
10
10
</refnamediv>
11
11

12
12
<refsect1 role="description">
13
13
&reftitle.description;
14
14
<methodsynopsis>
15
-
<type>array</type><methodname>pg_convert</methodname>
16
-
<methodparam><type>resource</type><parameter>connection</parameter></methodparam>
15
+
<type class="union"><type>array</type><type>false</type></type><methodname>pg_convert</methodname>
16
+
<methodparam><type>PgSql\Connection</type><parameter>connection</parameter></methodparam>
17
17
<methodparam><type>string</type><parameter>table_name</parameter></methodparam>
18
-
<methodparam><type>array</type><parameter>assoc_array</parameter></methodparam>
19
-
<methodparam choice="opt"><type>int</type><parameter>options</parameter><initializer>0</initializer></methodparam>
18
+
<methodparam><type>array</type><parameter>values</parameter></methodparam>
19
+
<methodparam choice="opt"><type>int</type><parameter>flags</parameter><initializer>0</initializer></methodparam>
20
20
</methodsynopsis>
21
21
<para>
22
22
<function>pg_convert</function> checks and converts the values in
23
-
<parameter>assoc_array</parameter> into suitable values for use in an SQL
23
+
<parameter>values</parameter> into suitable values for use in an SQL
24
24
statement. Precondition for <function>pg_convert</function> is the
25
25
existence of a table <parameter>table_name</parameter> which has at least
26
-
as many columns as <parameter>assoc_array</parameter> has elements. The
26
+
as many columns as <parameter>values</parameter> has elements. The
27
27
fieldnames in <parameter>table_name</parameter> must match the indices in
28
-
<parameter>assoc_array</parameter> and the corresponding datatypes must be
28
+
<parameter>values</parameter> and the corresponding datatypes must be
29
29
compatible. Returns an array with the converted values on success, &false;
30
30
otherwise.
31
31
</para>
32
32
<note>
33
33
<para>
34
-
Since PHP 5.6.0, it accepts boolean values. It converted to PostgreSQL
35
-
boolean. String representations of boolean value is also supported. &null; is
34
+
Boolean values are accepted and converted to PostgreSQL booleans.
35
+
String representations of boolean values are also supported. &null; is
36
36
converted to PostgreSQL NULL.
37
37
</para>
38
-
<para>
39
-
Prior to PHP 5.6.0, if there are boolean fields in <parameter>table_name</parameter>
40
-
don't use the constant &true; in <parameter>assoc_array</parameter>. It will be
41
-
converted to the string 'TRUE' which is no valid entry for boolean fields
42
-
in PostgreSQL. Use one of t, true, 1, y, yes instead.
43
-
</para>
44
38
</note>
45
39
</refsect1>
46
40

...
...
@@ -51,9 +45,7 @@
51
45
<varlistentry>
52
46
<term><parameter>connection</parameter></term>
53
47
<listitem>
54
-
<para>
55
-
PostgreSQL database connection resource.
56
-
</para>
48
+
&pgsql.parameter.connection;
57
49
</listitem>
58
50
</varlistentry>
59
51
<varlistentry>
...
...
@@ -65,7 +57,7 @@
65
57
</listitem>
66
58
</varlistentry>
67
59
<varlistentry>
68
-
<term><parameter>assoc_array</parameter></term>
60
+
<term><parameter>values</parameter></term>
69
61
<listitem>
70
62
<para>
71
63
Data to be converted.
...
...
@@ -73,7 +65,7 @@
73
65
</listitem>
74
66
</varlistentry>
75
67
<varlistentry>
76
-
<term><parameter>options</parameter></term>
68
+
<term><parameter>flags</parameter></term>
77
69
<listitem>
78
70
<para>
79
71
Any number of <constant>PGSQL_CONV_IGNORE_DEFAULT</constant>,
...
...
@@ -89,10 +81,43 @@
89
81
<refsect1 role="returnvalues">
90
82
&reftitle.returnvalues;
91
83
<para>
92
-
An <type>array</type> of converted values, or &false; on error.
84
+
An <type>array</type> of converted values, &return.falseforfailure;.
85
+
</para>
86
+
</refsect1>
87
+

88
+
<refsect1 role="errors">
89
+
&reftitle.errors;
90
+
<para>
91
+
A <classname>ValueError</classname> or <classname>TypeError</classname> is thrown
92
+
when the value or type of field does not match properly with a PostgreSQL's type.
93
93
</para>
94
94
</refsect1>
95
95

96
+
<refsect1 role="changelog">
97
+
&reftitle.changelog;
98
+
<informaltable>
99
+
<tgroup cols="2">
100
+
<thead>
101
+
<row>
102
+
<entry>&Version;</entry>
103
+
<entry>&Description;</entry>
104
+
</row>
105
+
</thead>
106
+
<tbody>
107
+
<row>
108
+
<entry>8.3.0</entry>
109
+
<entry>
110
+
Now throws a <classname>ValueError</classname> or <classname>TypeError</classname> error
111
+
when the value or type of field does not match properly with a PostgreSQL's type;
112
+
previously an <constant>E_WARNING</constant> was emitted.
113
+
</entry>
114
+
</row>
115
+
&pgsql.changelog.connection-object;
116
+
</tbody>
117
+
</tgroup>
118
+
</informaltable>
119
+
</refsect1>
120
+

96
121
<refsect1 role="examples">
97
122
&reftitle.examples;
98
123
<para>
...
...
@@ -117,32 +142,6 @@
117
142
</para>
118
143
</refsect1>
119
144

120
-
<refsect1 role="changelog">
121
-
&reftitle.changelog;
122
-
<para>
123
-
<informaltable>
124
-
<tgroup cols="2">
125
-
<thead>
126
-
<row>
127
-
<entry>&Version;</entry>
128
-
<entry>&Description;</entry>
129
-
</row>
130
-
</thead>
131
-
<tbody>
132
-
<row>
133
-
<entry>5.6.0</entry>
134
-
<entry>
135
-
No longer experimental. Boolean/NULL data types are supported. Unknown/unsupported
136
-
data types are escaped without validation. <function>pg_convert</function> could
137
-
be used with any data types.
138
-
</entry>
139
-
</row>
140
-
</tbody>
141
-
</tgroup>
142
-
</informaltable>
143
-
</para>
144
-
</refsect1>
145
-

146
145
<refsect1 role="seealso">
147
146
&reftitle.seealso;
148
147
<para>
...
...
@@ -156,7 +155,6 @@
156
155
</para>
157
156
</refsect1>
158
157
</refentry>
159
-

160
158
<!-- Keep this comment at the end of the file
161
159
Local variables:
162
160
mode: sgml
163
161