cvs: peardoc /en/package/database/db intro-fetch.xml
| From: | Daniel Convissor | Date: | Tue, 13 Apr 2004 21:33:41 +0000 |
| Subject: | cvs: peardoc /en/package/database/db intro-fetch.xml | ||
| Groups: | php.pear.doc | ||
| Request: | Send a blank email to pear-doc+get-3383@lists.php.net to get a copy of this message | ||
danielc Tue Apr 13 17:33:41 2004 EDT
Modified files:
/peardoc/en/package/database/db intro-fetch.xml
Log:
getRow() shouldn't be in while loop. Better english.
http://cvs.php.net/diff.php/peardoc/en/package/database/db/intro-fetch.xml?r1=1.23&r2=1.24&ty=u
Index: peardoc/en/package/database/db/intro-fetch.xml
diff -u peardoc/en/package/database/db/intro-fetch.xml:1.23
peardoc/en/package/database/db/intro-fetch.xml:1.24
--- peardoc/en/package/database/db/intro-fetch.xml:1.23 Tue Apr 13 15:11:21 2004
+++ peardoc/en/package/database/db/intro-fetch.xml Tue Apr 13 17:33:41 2004
@@ -1,4 +1,4 @@
-<!-- $Revision: 1.23 $ -->
+<!-- $Revision: 1.24 $ -->
<refentry id="package.database.db.intro-fetch">
<refnamediv>
@@ -112,7 +112,7 @@
Returns an associative array with the column
names as the array keys
<example>
- <title>Fetch a assoc. array</title>
+ <title>Fetch an associative array</title>
<programlisting role="php">
<![CDATA[
<?php
@@ -338,6 +338,8 @@
<?php
// Once you have a valid DB object named $db...
$numrows = $db->getOne('select count(id) from clients');
+
+// Returns: 3
?>
]]>
</programlisting>
@@ -349,9 +351,13 @@
<![CDATA[
<?php
// Once you have a valid DB object named $db...
-$sql = 'select name, address from clients where id=1';
-while ($row =& $db->getRow($sql)) {
- echo $row['name'] . ', ' . $row['address'] . "\n";
+$row =& $db->getRow('select name, address from clients');
+
+if (DB::isError($row)) {
+ die($row->getMessage());
+}
+
+echo $row['name'] . ', ' . $row['address'] . "\n";
}
?>
]]>
@@ -367,9 +373,8 @@
<?php
// Once you have a valid DB object named $db...
$data =& $db->getCol('SELECT name FROM clients');
-
/*
- * Will return:
+ * Returns:
* array(
* 0 => 'Stig',
* 1 => 'Jon',
@@ -391,7 +396,7 @@
// Once you have a valid DB object named $db...
$data =& $db->getAssoc('SELECT name, surname, phone FROM mytable');
/*
- * Will return:
+ * Returns:
* array(
* 'Peter' => array('Smith', '944679408'),
* 'Tomas' => array('Cox', '944679408'),
@@ -412,7 +417,7 @@
// Once you have a valid DB object named $db...
$data =& $db->getAll('SELECT id, text, date FROM mytable');
/*
- * Will return:
+ * Returns:
* array(
* 0 => array('4', 'four', '2004'),
* 1 => array('5', 'five', '2005'),