reference/pdo/pdostatement/bindcolumn.xml
082ddc19f53e6e254010de1a1fbbe485ff744ec1
...
...
@@ -1,4 +1,4 @@
1
-
<?xml version="1.0" encoding="UTF-8"?>
1
+
<?xml version="1.0" encoding="utf-8"?>
2
2
<!-- $Revision$ -->
3
3
<refentry xml:id="pdostatement.bindcolumn" xmlns="http://docbook.org/ns/docbook">
4
4
<refnamediv>
...
...
@@ -9,32 +9,32 @@
9
9
</refnamediv>
10
10
<refsect1 role="description">
11
11
&reftitle.description;
12
-
<methodsynopsis>
13
-
<type>bool</type><methodname>PDOStatement::bindColumn</methodname>
14
-
<methodparam><type>mixed</type><parameter>column</parameter></methodparam>
15
-
<methodparam><type>mixed</type><parameter role="reference">param</parameter></methodparam>
16
-
<methodparam choice="opt"><type>int</type><parameter>type</parameter></methodparam>
17
-
<methodparam choice="opt"><type>int</type><parameter>maxlen</parameter></methodparam>
18
-
<methodparam choice="opt"><type>mixed</type><parameter>driverdata</parameter></methodparam>
19
-
</methodsynopsis>
12
+
<methodsynopsis role="PDOStatement">
13
+
<modifier>public</modifier> <type>bool</type><methodname>PDOStatement::bindColumn</methodname>
14
+
<methodparam><type class="union"><type>string</type><type>int</type></type><parameter>column</parameter></methodparam>
15
+
<methodparam><type>mixed</type><parameter role="reference">var</parameter></methodparam>
16
+
<methodparam choice="opt"><type>int</type><parameter>type</parameter><initializer>PDO::PARAM_STR</initializer></methodparam>
17
+
<methodparam choice="opt"><type>int</type><parameter>maxLength</parameter><initializer>0</initializer></methodparam>
18
+
<methodparam choice="opt"><type>mixed</type><parameter>driverOptions</parameter><initializer>&null;</initializer></methodparam>
19
+
</methodsynopsis>
20
20

21
21
<para>
22
-
<function>PDOStatement::bindColumn</function> arranges to have a
22
+
<methodname>PDOStatement::bindColumn</methodname> arranges to have a
23
23
particular variable bound to a given column in the result-set from a
24
-
query. Each call to <function>PDOStatement::fetch</function> or
25
-
<function>PDOStatement::fetchAll</function> will update all the variables
24
+
query. Each call to <methodname>PDOStatement::fetch</methodname> or
25
+
<methodname>PDOStatement::fetchAll</methodname> will update all the variables
26
26
that are bound to columns.
27
27
</para>
28
28
<note>
29
29
<para>
30
30
Since information about the columns is not always available to PDO until
31
31
the statement is executed, portable applications should call this
32
-
function <emphasis>after</emphasis> <function>PDOStatement::execute</function>.
32
+
function <emphasis>after</emphasis> <methodname>PDOStatement::execute</methodname>.
33
33
</para>
34
34
<para>
35
35
However, to be able to bind a LOB column as a stream when using the
36
36
<emphasis>PgSQL driver</emphasis>, applications should call this method
37
-
<emphasis>before</emphasis> calling <function>PDOStatement::execute</function>,
37
+
<emphasis>before</emphasis> calling <methodname>PDOStatement::execute</methodname>,
38
38
otherwise the large object OID will be returned as an integer.
39
39
</para>
40
40
</note>
...
...
@@ -55,7 +55,7 @@
55
55
</listitem>
56
56
</varlistentry>
57
57
<varlistentry>
58
-
<term><parameter>param</parameter></term>
58
+
<term><parameter>var</parameter></term>
59
59
<listitem>
60
60
<para>
61
61
Name of the PHP variable to which the column will be bound.
...
...
@@ -66,12 +66,13 @@
66
66
<term><parameter>type</parameter></term>
67
67
<listitem>
68
68
<para>
69
-
Data type of the parameter, specified by the PDO::PARAM_* constants.
69
+
Data type of the parameter, specified by the <link linkend="pdo.constants"><literal>PDO::PARAM_*</literal>
70
+
constants</link>.
70
71
</para>
71
72
</listitem>
72
73
</varlistentry>
73
74
<varlistentry>
74
-
<term><parameter>maxlen</parameter></term>
75
+
<term><parameter>maxLength</parameter></term>
75
76
<listitem>
76
77
<para>
77
78
A hint for pre-allocation.
...
...
@@ -79,7 +80,7 @@
79
80
</listitem>
80
81
</varlistentry>
81
82
<varlistentry>
82
-
<term><parameter>driverdata</parameter></term>
83
+
<term><parameter>driverOptions</parameter></term>
83
84
<listitem>
84
85
<para>
85
86
Optional parameter(s) for the driver.
...
...
@@ -97,6 +98,11 @@
97
98
</para>
98
99
</refsect1>
99
100

101
+
<refsect1 role="errors">
102
+
&reftitle.errors;
103
+
&pdo.errors;
104
+
</refsect1>
105
+

100
106
<refsect1 role="examples">
101
107
&reftitle.examples;
102
108
<para>
...
...
@@ -112,33 +118,22 @@
112
118
<programlisting role="php">
113
119
<![CDATA[
114
120
<?php
115
-
function readData($dbh) {
116
-
$sql = 'SELECT name, colour, calories FROM fruit';
117
-
try {
118
-
$stmt = $dbh->prepare($sql);
119
-
$stmt->execute();
121
+
$stmt = $dbh->prepare('SELECT name, colour, calories FROM fruit');
122
+
$stmt->execute();
120
123

121
-
/* Bind by column number */
122
-
$stmt->bindColumn(1, $name);
123
-
$stmt->bindColumn(2, $colour);
124
+
/* Bind by column number */
125
+
$stmt->bindColumn(1, $name);
126
+
$stmt->bindColumn(2, $colour);
124
127

125
-
/* Bind by column name */
126
-
$stmt->bindColumn('calories', $cals);
128
+
/* Bind by column name */
129
+
$stmt->bindColumn('calories', $cals);
127
130

128
-
while ($row = $stmt->fetch(PDO::FETCH_BOUND)) {
129
-
$data = $name . "\t" . $colour . "\t" . $cals . "\n";
130
-
print $data;
131
-
}
132
-
}
133
-
catch (PDOException $e) {
134
-
print $e->getMessage();
135
-
}
131
+
while ($stmt->fetch(PDO::FETCH_BOUND)) {
132
+
print $name . "\t" . $colour . "\t" . $cals . "\n";
136
133
}
137
-
readData($dbh);
138
-
?>
139
-
]]>
134
+
]]>
140
135
</programlisting>
141
-
&example.outputs;
136
+
&example.outputs.similar;
142
137
<screen>
143
138
<![CDATA[
144
139
apple red 150
...
...
@@ -157,16 +152,15 @@ strawberry red 25
157
152
&reftitle.seealso;
158
153
<para>
159
154
<simplelist>
160
-
<member><function>PDOStatement::execute</function></member>
161
-
<member><function>PDOStatement::fetch</function></member>
162
-
<member><function>PDOStatement::fetchAll</function></member>
163
-
<member><function>PDOStatement::fetchColumn</function></member>
155
+
<member><methodname>PDOStatement::execute</methodname></member>
156
+
<member><methodname>PDOStatement::fetch</methodname></member>
157
+
<member><methodname>PDOStatement::fetchAll</methodname></member>
158
+
<member><methodname>PDOStatement::fetchColumn</methodname></member>
164
159
</simplelist>
165
160
</para>
166
161
</refsect1>
167
162

168
163
</refentry>
169
-

170
164
<!-- Keep this comment at the end of the file
171
165
Local variables:
172
166
mode: sgml
173
167