reference/pdo_sqlite/PDO/sqliteCreateFunction.xml
9e0f03ac354d797d1d16c0fcc1663e5e170f2727
...
...
@@ -14,7 +14,8 @@
14
14
<modifier>public</modifier> <type>bool</type><methodname>PDO::sqliteCreateFunction</methodname>
15
15
<methodparam><type>string</type><parameter>function_name</parameter></methodparam>
16
16
<methodparam><type>callable</type><parameter>callback</parameter></methodparam>
17
-
<methodparam choice="opt"><type>int</type><parameter>num_args</parameter></methodparam>
17
+
<methodparam choice="opt"><type>int</type><parameter>num_args</parameter><initializer>-1</initializer></methodparam>
18
+
<methodparam choice="opt"><type>int</type><parameter>flags</parameter><initializer>0</initializer></methodparam>
18
19
</methodsynopsis>
19
20
&warn.experimental.func;
20
21

...
...
@@ -53,14 +54,52 @@
53
54
<link linkend="language.types.intro">scalar type</link>).
54
55
</simpara>
55
56
</note>
57
+
<para>
58
+
This function need to be defined as:
59
+
<methodsynopsis>
60
+
<type>mixed</type><methodname><replaceable>callback</replaceable></methodname>
61
+
<methodparam><type>mixed</type><parameter>value</parameter></methodparam>
62
+
<methodparam rep="repeat"><type>mixed</type><parameter>values</parameter></methodparam>
63
+
</methodsynopsis>
64
+
<variablelist>
65
+
<varlistentry>
66
+
<term><parameter>value</parameter></term>
67
+
<listitem>
68
+
<para>
69
+
The first argument passed to the SQL function.
70
+
</para>
71
+
</listitem>
72
+
</varlistentry>
73
+
<varlistentry>
74
+
<term><parameter>values</parameter></term>
75
+
<listitem>
76
+
<para>
77
+
Further arguments passed to the SQL function.
78
+
</para>
79
+
</listitem>
80
+
</varlistentry>
81
+
</variablelist>
82
+
</para>
56
83
</listitem>
57
84
</varlistentry>
58
85
<varlistentry>
59
86
<term><parameter>num_args</parameter></term>
60
87
<listitem>
61
88
<para>
62
-
Hint to the SQLite parser if the callback function accepts a
63
-
predetermined number of arguments.
89
+
The number of arguments that the SQL function takes. If
90
+
this parameter is <literal>-1</literal>, then the SQL function may take
91
+
any number of arguments.
92
+
</para>
93
+
</listitem>
94
+
</varlistentry>
95
+
<varlistentry>
96
+
<term><parameter>flags</parameter></term>
97
+
<listitem>
98
+
<para>
99
+
A bitwise conjunction of flags. Currently, only
100
+
<constant>PDO::SQLITE_DETERMINISTIC</constant> is supported, which specifies
101
+
that the function always returns the same result given the same inputs
102
+
within a single SQL statement.
64
103
</para>
65
104
</listitem>
66
105
</varlistentry>
...
...
@@ -75,6 +114,28 @@
75
114
</para>
76
115
</refsect1>
77
116

117
+
<refsect1 role="changelog">
118
+
&reftitle.changelog;
119
+
<informaltable>
120
+
<tgroup cols="2">
121
+
<thead>
122
+
<row>
123
+
<entry>&Version;</entry>
124
+
<entry>&Description;</entry>
125
+
</row>
126
+
</thead>
127
+
<tbody>
128
+
<row>
129
+
<entry>7.1.4</entry>
130
+
<entry>
131
+
The <parameter>flags</parameter> parameter has been added.
132
+
</entry>
133
+
</row>
134
+
</tbody>
135
+
</tgroup>
136
+
</informaltable>
137
+
</refsect1>
138
+

78
139
<refsect1 role="examples">
79
140
&reftitle.examples;
80
141
<para>
...
...
@@ -100,7 +161,7 @@ $rows = $db->query('SELECT md5rev(filename) FROM files')->fetchAll();
100
161
In this example, we have a function that calculates the md5 sum of a
101
162
string, and then reverses it. When the SQL statement executes, it
102
163
returns the value of the filename transformed by our function. The data
103
-
returned in <parameter>$rows</parameter> contains the processed result.
164
+
returned in <literal>$rows</literal> contains the processed result.
104
165
</para>
105
166
<para>
106
167
The beauty of this technique is that you do not need to process the
...
...
@@ -138,12 +199,6 @@ $rows = $db->query("SELECT php('md5', filename) from files")->fetchAll();
138
199
native SQL functions.
139
200
</para>
140
201
</tip>
141
-
<note>
142
-
<para>
143
-
This method is not available with the SQLite2 driver.
144
-
Use the old style sqlite API for that instead.
145
-
</para>
146
-
</note>
147
202
</refsect1>
148
203

149
204
<refsect1 role="seealso">
150
205