-
Notifications
You must be signed in to change notification settings - Fork 788
/
Copy pathdb2-fetch-object.xml
151 lines (141 loc) · 4.38 KB
/
db2-fetch-object.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- Generated by xml_proto.php v2.2. Found in /scripts directory of phpdoc. -->
<refentry xml:id="function.db2-fetch-object" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>db2_fetch_object</refname>
<refpurpose>
Returns an object with properties representing columns in the fetched row
</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type class="union"><type>stdClass</type><type>false</type></type><methodname>db2_fetch_object</methodname>
<methodparam><type>resource</type><parameter>stmt</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>row_number</parameter><initializer>-1</initializer></methodparam>
</methodsynopsis>
<para>
Returns an object in which each property represents a column returned in
the row fetched from a result set.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>stmt</parameter></term>
<listitem>
<para>
A valid <literal>stmt</literal> resource containing a result set.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>row_number</parameter></term>
<listitem>
<para>
Requests a specific 1-indexed row from the result set. Passing this
parameter results in a PHP warning if the result set uses a
forward-only cursor.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns an object representing a single row in the result set. The
properties of the object map to the names of the columns in the result set.
</para>
<para>
The IBM DB2, Cloudscape, and Apache Derby database servers typically fold
column names to upper-case, so the object properties will reflect that case.
</para>
<para>
If your SELECT statement calls a scalar function to modify the value
of a column, the database servers return the column number as the name of
the column in the result set. If you prefer a more descriptive column name
and object property, you can use the AS clause to assign a name to the
column in the result set.
</para>
<para>
Returns &false; if no row was retrieved.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>A <function>db2_fetch_object</function> example</title>
<para>
The following example issues a SELECT statement with a scalar function,
RTRIM, that removes whitespace from the end of the column. Rather than
creating an object with the properties "BREED" and "2", we use the AS
clause in the SELECT statement to assign the name "name" to the modified
column. The database server folds the column names to upper-case,
resulting in an object with the properties "BREED" and "NAME".
</para>
<programlisting role="php">
<![CDATA[
<?php
$conn = db2_connect($database, $user, $password);
$sql = "SELECT breed, RTRIM(name) AS name
FROM animals
WHERE id = ?";
if ($conn) {
$stmt = db2_prepare($conn, $sql);
db2_execute($stmt, array(0));
while ($pet = db2_fetch_object($stmt)) {
echo "Come here, {$pet->NAME}, my little {$pet->BREED}!";
}
db2_close($conn);
}
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Come here, Pook, my little cat!
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>db2_fetch_array</function></member>
<member><function>db2_fetch_assoc</function></member>
<member><function>db2_fetch_both</function></member>
<member><function>db2_fetch_row</function></member>
<member><function>db2_result</function></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->