cvs: peardoc /en/package/database/db intro-fetch.xml

From: Date: Sun, 09 Jan 2005 16:57:16 +0000
Subject: cvs: peardoc /en/package/database/db intro-fetch.xml
Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-5384@lists.php.net to get a copy of this message
danielc Sun Jan 9 11:57:16 2005 EDT Modified files: /peardoc/en/package/database/db intro-fetch.xml Log: * Have examples use fetchInto() instead of fetchRow() because it's more efficient. http://cvs.php.net/diff.php/peardoc/en/package/database/db/intro-fetch.xml?r1=1.47&r2=1.48&ty=u Index: peardoc/en/package/database/db/intro-fetch.xml diff -u peardoc/en/package/database/db/intro-fetch.xml:1.47 peardoc/en/package/database/db/intro-fetch.xml:1.48 --- peardoc/en/package/database/db/intro-fetch.xml:1.47 Sun May 23 05:48:26 2004 +++ peardoc/en/package/database/db/intro-fetch.xml Sun Jan 9 11:57:15 2005 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1" ?> -<!-- $Revision: 1.47 $ --> +<!-- $Revision: 1.48 $ --> <refentry id="package.database.db.intro-fetch"> <refnamediv> @@ -53,13 +53,13 @@ // Get each row of data on each iteration until // there are no more rows -while ($row =& $res->fetchRow()) { +while ($res->fetchInto($row)) { // Assuming DB's default fetchmode is DB_FETCHMODE_ORDERED echo $row[0] . "\n"; } -// Or, you could have done the same thing using fetchInto() -// while ($res->fetchInto($row)) { +// Or, you could have done the same thing using fetchRow() +// while ($row =& $res->fetchRow()) { // // Assuming DB's default fetchmode is DB_FETCHMODE_ORDERED // echo $row[0] . "\n"; // } @@ -161,7 +161,7 @@ // Once you have a valid DB object named $db... $res =& $db->query('SELECT * FROM users'); -while ($row =& $res->fetchRow(DB_FETCHMODE_ASSOC)) { +while ($res->fetchInto($row, DB_FETCHMODE_ASSOC)) { echo $row['id'] . "\n"; } ?> @@ -178,7 +178,7 @@ $res =& $db->query('SELECT * FROM users'); -while ($row =& $res->fetchRow()) { +while ($res->fetchInto($row)) { echo $row['id'] . "\n"; } ?> @@ -213,7 +213,7 @@ $to = $from + $resPage; foreach (range($from, $to) as $rowNum) { - if (!$row =& $res->fetchRow($fetchmode, $rowNum)) { + if (!$res->fetchInto($row, DB_FETCHMODE_ORDERED, $rowNum)) { break; } echo $row[0] . "\n"; @@ -261,7 +261,7 @@ <?php // Once you have a valid DB object named $db... $res =& $db->query('SELECT name, address FROM clients'); -while ($row =& $res->fetchRow()) { +while ($res->fetchInto($row)) { echo $row['name'] . ', ' . $row['address'] . "\n"; } $res->free();

« previous php.pear.doc (#5384) next »