reference/pdo/pdostatement/fetchcolumn.xml
28529d3539b850e870e3aa97570f4db0e53daa03
...
...
@@ -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.fetchcolumn" xmlns="http://docbook.org/ns/docbook">
4
4
<refnamediv>
...
...
@@ -10,15 +10,24 @@
10
10

11
11
<refsect1 role="description">
12
12
&reftitle.description;
13
-
<methodsynopsis>
14
-
<type>string</type><methodname>PDOStatement::fetchColumn</methodname>
15
-
<methodparam choice="opt"><type>int</type><parameter>column_number</parameter><initializer>0</initializer></methodparam>
13
+
<methodsynopsis role="PDOStatement">
14
+
<modifier>public</modifier> <type>mixed</type><methodname>PDOStatement::fetchColumn</methodname>
15
+
<methodparam choice="opt"><type>int</type><parameter>column</parameter><initializer>0</initializer></methodparam>
16
16
</methodsynopsis>
17
17

18
18
<para>
19
19
Returns a single column from the next row of a result set or &false; if
20
20
there are no more rows.
21
21
</para>
22
+

23
+
<note>
24
+
<para>
25
+
<methodname>PDOStatement::fetchColumn</methodname> should not be used to
26
+
retrieve boolean columns, as it is impossible to distinguish a value of
27
+
&false; from there being no more rows to retrieve. Use
28
+
<methodname>PDOStatement::fetch</methodname> instead.
29
+
</para>
30
+
</note>
22
31
</refsect1>
23
32

24
33
<refsect1 role="parameters">
...
...
@@ -26,11 +35,11 @@
26
35
<para>
27
36
<variablelist>
28
37
<varlistentry>
29
-
<term><parameter>column_number</parameter></term>
38
+
<term><parameter>column</parameter></term>
30
39
<listitem>
31
40
<para>
32
41
0-indexed number of the column you wish to retrieve from the row. If
33
-
no value is supplied, <function>PDOStatement::fetchColumn</function>
42
+
no value is supplied, <methodname>PDOStatement::fetchColumn</methodname>
34
43
fetches the first column.
35
44
</para>
36
45
</listitem>
...
...
@@ -42,17 +51,22 @@
42
51
<refsect1 role="returnvalues">
43
52
&reftitle.returnvalues;
44
53
<para>
45
-
<function>PDOStatement::fetchColumn</function> returns a single column
46
-
in the next row of a result set.
54
+
<methodname>PDOStatement::fetchColumn</methodname> returns a single column
55
+
from the next row of a result set or &false; if there are no more rows.
47
56
</para>
48
57
<warning>
49
58
<para>
50
59
There is no way to return another column from the same row if you
51
-
use <function>PDOStatement::fetchColumn</function> to retrieve data.
60
+
use <methodname>PDOStatement::fetchColumn</methodname> to retrieve data.
52
61
</para>
53
62
</warning>
54
63
</refsect1>
55
64

65
+
<refsect1 role="errors">
66
+
&reftitle.errors;
67
+
&pdo.errors;
68
+
</refsect1>
69
+

56
70
<refsect1 role="examples">
57
71
&reftitle.examples;
58
72
<para>
...
...
@@ -63,23 +77,22 @@
63
77
$sth = $dbh->prepare("SELECT name, colour FROM fruit");
64
78
$sth->execute();
65
79

66
-
/* Fetch the first column from the next row in the result set */
67
-
print("Fetch the first column from the next row in the result set:\n");
80
+
print "Fetch the first column from the first row in the result set:\n";
68
81
$result = $sth->fetchColumn();
69
-
print("name = $result\n");
82
+
print "name = $result\n";
70
83

71
-
print("Fetch the second column from the next row in the result set:\n");
84
+
print "Fetch the second column from the second row in the result set:\n";
72
85
$result = $sth->fetchColumn(1);
73
-
print("colour = $result\n");
86
+
print "colour = $result\n";
74
87
?>
75
88
]]>
76
89
</programlisting>
77
90
&example.outputs;
78
91
<screen>
79
92
<![CDATA[
80
-
Fetch the first column from the next row in the result set:
93
+
Fetch the first column from the first row in the result set:
81
94
name = lemon
82
-
Fetch the second column from the next row in the result set:
95
+
Fetch the second column from the second row in the result set:
83
96
colour = red
84
97
]]>
85
98
</screen>
...
...
@@ -91,16 +104,15 @@ colour = red
91
104
&reftitle.seealso;
92
105
<para>
93
106
<simplelist>
94
-
<member><function>PDO::query</function></member>
95
-
<member><function>PDOStatement::fetch</function></member>
96
-
<member><function>PDOStatement::fetchAll</function></member>
97
-
<member><function>PDO::prepare</function></member>
98
-
<member><function>PDOStatement::setFetchMode</function></member>
107
+
<member><methodname>PDO::query</methodname></member>
108
+
<member><methodname>PDOStatement::fetch</methodname></member>
109
+
<member><methodname>PDOStatement::fetchAll</methodname></member>
110
+
<member><methodname>PDO::prepare</methodname></member>
111
+
<member><methodname>PDOStatement::setFetchMode</methodname></member>
99
112
</simplelist>
100
113
</para>
101
114
</refsect1>
102
115
</refentry>
103
-

104
116
<!-- Keep this comment at the end of the file
105
117
Local variables:
106
118
mode: sgml
107
119