dbs Fri Nov 19 17:41:59 2004 EDT
Modified files:
/phpdoc/en/reference/pdo/functions PDOStatement-fetch.xml
PDOStatement-fetchAll.xml
PDOStatement-fetchSingle.xml
Log:
Update examples, include warning for fetchAll about resource requirements.
http://cvs.php.net/diff.php/phpdoc/en/reference/pdo/functions/PDOStatement-fetch.xml?r1=1.2&r2=1.3&ty=u
Index: phpdoc/en/reference/pdo/functions/PDOStatement-fetch.xml
diff -u phpdoc/en/reference/pdo/functions/PDOStatement-fetch.xml:1.2
phpdoc/en/reference/pdo/functions/PDOStatement-fetch.xml:1.3
--- phpdoc/en/reference/pdo/functions/PDOStatement-fetch.xml:1.2 Fri Nov
19 17:21:35 2004
+++ phpdoc/en/reference/pdo/functions/PDOStatement-fetch.xml Fri Nov 19
17:41:59 2004
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='iso-8859-1'?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- Generated by xml_proto.php v2.1. Found in /scripts directory of phpdoc.
-->
<refentry id="function.PDOStatement-fetch">
<refnamediv>
@@ -56,6 +56,9 @@
<programlisting role="php">
<![CDATA[
<?php
+$sth = $dbh->prepare("SELECT name, colour FROM fruit");
+$sth->execute();
+
/* Exercise PDOStatement::fetch styles */
print("PDO_FETCH_ASSOC: ");
print("Return next row as an array indexed by column name\n");
http://cvs.php.net/diff.php/phpdoc/en/reference/pdo/functions/PDOStatement-fetchAll.xml?r1=1.3&r2=1.4&ty=u
Index: phpdoc/en/reference/pdo/functions/PDOStatement-fetchAll.xml
diff -u phpdoc/en/reference/pdo/functions/PDOStatement-fetchAll.xml:1.3
phpdoc/en/reference/pdo/functions/PDOStatement-fetchAll.xml:1.4
--- phpdoc/en/reference/pdo/functions/PDOStatement-fetchAll.xml:1.3 Fri Nov
19 17:21:35 2004
+++ phpdoc/en/reference/pdo/functions/PDOStatement-fetchAll.xml Fri Nov 19
17:41:59 2004
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='iso-8859-1'?>
-<!-- $Revision: 1.3 $ -->
+<!-- $Revision: 1.4 $ -->
<!-- Generated by xml_proto.php v2.1. Found in /scripts directory of phpdoc.
-->
<refentry id="function.PDOStatement-fetchAll">
<refnamediv>
@@ -25,11 +25,22 @@
<function>PDOStatement::fetch</function>.
<parameter>fetch_style</parameter>
defaults to <literal>PDO_FETCH_BOTH</literal>.
</para>
+ <para>
+ Using this method to fetch large result sets will result in a heavy
+ demand on system and possibly network resources. Rather than retrieving
+ all of the data and manipulating it in PHP, consider using the database
+ server to manipulate the result sets. For example, use the WHERE and
+ SORT BY clauses in SQL to restrict results before retrieving and
+ processing them with PHP.
+ </para>
<example><title>Fetch all remaining rows in a result set</title>
<programlisting role="php">
<![CDATA[
<?php
+$sth = $dbh->prepare("SELECT name, colour FROM fruit");
+$sth->execute();
+
/* Fetch all of the remaining rows in the result set */
print("Fetch all of the remaining rows in the result set:\n");
$result = $sth->fetchAll();
http://cvs.php.net/diff.php/phpdoc/en/reference/pdo/functions/PDOStatement-fetchSingle.xml?r1=1.2&r2=1.3&ty=u
Index: phpdoc/en/reference/pdo/functions/PDOStatement-fetchSingle.xml
diff -u phpdoc/en/reference/pdo/functions/PDOStatement-fetchSingle.xml:1.2
phpdoc/en/reference/pdo/functions/PDOStatement-fetchSingle.xml:1.3
--- phpdoc/en/reference/pdo/functions/PDOStatement-fetchSingle.xml:1.2 Thu Nov
11 03:16:32 2004
+++ phpdoc/en/reference/pdo/functions/PDOStatement-fetchSingle.xml Fri Nov
19 17:41:59 2004
@@ -1,11 +1,11 @@
<?xml version='1.0' encoding='iso-8859-1'?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- Generated by xml_proto.php v2.1. Found in /scripts directory of phpdoc.
-->
<refentry id="function.PDOStatement-fetchSingle">
<refnamediv>
<refname>PDOStatement::fetchSingle</refname>
<refpurpose>
- Returns a data of the first column in the result set
+ Returns the first column in the next row of a result set
</refpurpose>
</refnamediv>
<refsect1>
@@ -15,7 +15,44 @@
<void/>
</methodsynopsis>
- &warn.undocumented.func;
+ &warn.experimental.func;
+ <para>
+ <function>PDOStatement::fetchSingle</function> returns the first column
+ in the next row of a result set as a <literal>string</literal> value.
+ </para>
+ <warning>
+ <para>
+ There is no way to return the second or subsequent columns from a row
+ if you use this method to retrieve data.
+ </para>
+ </warning>
+
+ <example><title>Return first column of the next row</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$sth = $dbh->prepare("SELECT name, colour FROM fruit");
+$sth->execute();
+
+/* Fetch the first column from the next row in the result set */
+print("Fetch the first column from the next row in the result set:\n");
+$result = $sth->fetchSingle();
+print("$result\n");
+
+$result = $sth->fetchSingle();
+print("$result\n");
+?>
+]]>
+ </programlisting>
+ </example>
+ &example.outputs;
+ <screen>
+<![CDATA[
+Fetch the first column from the next row in the result set:
+lemon
+orange
+]]>
+ </screen>
</refsect1>
</refentry>