cvs: phpdoc-zh /reference/pgsql/functions pg-fetch-object.xml
| From: | Xiao shengwen | Date: | Thu, 24 Jul 2003 07:39:11 +0000 |
| Subject: | cvs: phpdoc-zh /reference/pgsql/functions pg-fetch-object.xml | ||
| Groups: | php.doc.zh | ||
| Request: | Send a blank email to doc-zh+get-1588@lists.php.net to get a copy of this message | ||
yincheng Thu Jul 24 03:39:11 2003 EDT
Modified files:
/phpdoc-zh/reference/pgsql/functions pg-fetch-object.xml
Log:
ok
Index: phpdoc-zh/reference/pgsql/functions/pg-fetch-object.xml
diff -u phpdoc-zh/reference/pgsql/functions/pg-fetch-object.xml:1.4
phpdoc-zh/reference/pgsql/functions/pg-fetch-object.xml:1.5
--- phpdoc-zh/reference/pgsql/functions/pg-fetch-object.xml:1.4 Mon Feb 24 02:50:52 2003
+++ phpdoc-zh/reference/pgsql/functions/pg-fetch-object.xml Thu Jul 24 03:39:11 2003
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="gb2312"?>
-<!-- $Revision: 1.4 $ -->
-<!-- $Author: dallas $ -->
-<!-- EN-Revision: 1.9 Maintainer: dallas Status: ready -->
+<!-- $Revision: 1.5 $ -->
+<!-- $Author: yincheng $ -->
+<!-- EN-Revision: 1.10 Maintainer: dallas Status: ready -->
<refentry id="function.pg-fetch-object">
<refnamediv>
<refname>pg_fetch_object</refname>
@@ -40,61 +40,46 @@
</note>
<para>
<example>
- <title>Postgres fetch object</title>
+ <title><function>pg_fetch_object</function></title>
<programlisting role="php">
<![CDATA[
<?php
-$database = "verlag";
-$db_conn = pg_connect ("host=localhost port=5432 dbname=$database");
-if (!$db_conn): ?>
- <H1>Failed connecting to postgres database <?php echo $database ?></H1>
<?php
- exit;
-endif;
-$qu = pg_query ($db_conn, "SELECT * FROM verlag ORDER BY autor");
-$row = 0; // postgres needs a row counter other dbs might not
+$database = "store";
-while ($data = pg_fetch_object ($qu, $row)) {
- echo $data->autor." (";
- echo $data->jahr ."): ";
- echo $data->titel."<BR>";
- $row++;
+$db_conn = pg_connect("host=localhost port=5432 dbname=$database");
+if (!$db_conn) {
+ echo "Failed connecting to postgres database $database\n";
+ exit;
}
-?>
-<PRE>
-<?php
-$fields[] = Array ("autor", "Author");
-$fields[] = Array ("jahr", " Year");
-$fields[] = Array ("titel", " Title");
-
-$row= 0; // postgres needs a row counter other dbs might not
-while ($data = pg_fetch_object ($qu, $row)) {
- echo "----------\n";
- reset ($fields);
- while (list (,$item) = each ($fields)):
- echo $item[1].": ".$data->$item[0]."\n";
- endwhile;
+
+$qu = pg_query($db_conn, "SELECT * FROM books ORDER BY author");
+
+$row = 0; // postgres needs a row counter
+
+while ($data = pg_fetch_object($qu, $row)) {
+ echo $data->author . " (";
+ echo $data->year . "): ";
+ echo $data->title . "<br />";
$row++;
}
-echo "----------\n";
-?>
-</PRE>
-<?php
+
pg_free_result ($qu);
pg_close ($db_conn);
+
?>
]]>
</programlisting>
</example>
</para>
- <para>
- ²Î¼û
<function>pg_query</function>£¬<function>pg_fetch_array</function>£¬<function>pg_fetch_row</function>
ºÍ <function>pg_fetch_result</function>¡£
- </para>
<note>
<para>
´Ó 4.1.0 ¿ªÊ¼£¬<parameter>row</parameter>
³ÉΪ¿ÉÑ¡²ÎÊý¡£Ã¿´Îµ÷ÓÃ
<function>pg_fetch_object</function>£¬ÄÚ²¿µÄÐмÆÊýÆ÷¶¼»á¼ÓÒ»¡£
</para>
</note>
+ <para>
+ ²Î¼û
<function>pg_query</function>£¬<function>pg_fetch_array</function>£¬<function>pg_fetch_row</function>
ºÍ <function>pg_fetch_result</function>¡£
+ </para>
</refsect1>
</refentry>