reference/pdo/pdostatement/bindcolumn.xml
082ddc19f53e6e254010de1a1fbbe485ff744ec1
...
...
@@ -9,32 +9,32 @@
9
9
</refnamediv>
10
10
<refsect1 role="description">
11
11
&reftitle.description;
12
-
<methodsynopsis>
13
-
<modifier>public</modifier> <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,14 +66,13 @@
66
66
<term><parameter>type</parameter></term>
67
67
<listitem>
68
68
<para>
69
-
Data type of the parameter, specified by the <link
70
-
linkend="pdo.constants"><literal>PDO::PARAM_*</literal>
69
+
Data type of the parameter, specified by the <link linkend="pdo.constants"><literal>PDO::PARAM_*</literal>
71
70
constants</link>.
72
71
</para>
73
72
</listitem>
74
73
</varlistentry>
75
74
<varlistentry>
76
-
<term><parameter>maxlen</parameter></term>
75
+
<term><parameter>maxLength</parameter></term>
77
76
<listitem>
78
77
<para>
79
78
A hint for pre-allocation.
...
...
@@ -81,7 +80,7 @@
81
80
</listitem>
82
81
</varlistentry>
83
82
<varlistentry>
84
-
<term><parameter>driverdata</parameter></term>
83
+
<term><parameter>driverOptions</parameter></term>
85
84
<listitem>
86
85
<para>
87
86
Optional parameter(s) for the driver.
...
...
@@ -99,6 +98,11 @@
99
98
</para>
100
99
</refsect1>
101
100

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

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

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

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

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

170
163
</refentry>
171
-

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