Minor example changes; incorporating user notes

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@176739 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Kenneth Schwartz 2005-01-09 17:15:09 +00:00
parent 5bb1f07bbf
commit bd9f1e1d38
3 changed files with 30 additions and 16 deletions

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.9 $ -->
<!-- $Revision: 1.10 $ -->
<!-- splitted from ./en/functions/pgsql.xml, last change in rev 1.2 -->
<refentry id="function.pg-fetch-array">
<refnamediv>
@ -37,10 +37,11 @@
<parameter>result_type</parameter> is a constant and can take the
following values: <constant>PGSQL_ASSOC</constant>,
<constant>PGSQL_NUM</constant>, and <constant>PGSQL_BOTH</constant>.
<function>pg_fetch_array</function> returns associative array
that has field name as key for <constant>PGSQL_ASSOC</constant>, field index as key
with <constant>PGSQL_NUM</constant> and both field name/index as key with
<constant>PGSQL_BOTH</constant>. Default is <constant>PGSQL_BOTH</constant>.
Using <constant>PGSQL_NUM</constant>, <function>pg_fetch_array</function>
will return an array with numerical indices, using
<constant>PGSQL_ASSOC</constant> will return only associative indices
while <constant>PGSQL_BOTH</constant>, the default, will return both
numerical and associative indices.
<note>
<para>
<parameter>result_type</parameter> was added in PHP 4.0.
@ -65,17 +66,26 @@ if (!$conn) {
exit;
}
$result = pg_query($conn, "SELECT * FROM authors");
$result = pg_query($conn, "SELECT author, email FROM authors");
if (!$result) {
echo "An error occured.\n";
exit;
}
$arr = pg_fetch_array($result, 0, PGSQL_NUM);
echo $arr[0] . " <- array\n";
echo $arr[0] . " <- Row 1 Author\n";
echo $arr[1] . " <- Row 1 E-mail\n";
$arr = pg_fetch_array($result, 1, PGSQL_ASSOC);
echo $arr["author"] . " <- array\n";
// As of PHP 4.1.0, the row parameter is optional; NULL can be passed instead,
// to pass a result_type. Successive calls to pg_fetch_array will return the
// next row.
$arr = pg_fetch_array($result, NULL, PGSQL_ASSOC);
echo $arr["author"] . " <- Row 2 Author\n";
echo $arr["email"] . " <- Row 2 E-mail\n";
$arr = pg_fetch_array($result);
echo $arr["author"] . " <- Row 3 Author\n";
echo $arr[1] . " <- Row 3 E-mail\n";
?>
]]>
@ -86,7 +96,7 @@ echo $arr["author"] . " <- array\n";
<para>
From 4.1.0, <parameter>row</parameter> became optional.
Calling <function>pg_fetch_array</function> will increment
internal row counter by 1.
the internal row counter by one.
</para>
</note>
<para>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.7 $ -->
<!-- $Revision: 1.8 $ -->
<!-- splitted from ./en/functions/pgsql.xml, last change in rev 1.2 -->
<refentry id="function.pg-fetch-assoc">
<refnamediv>
@ -63,6 +63,13 @@ while ($row = pg_fetch_assoc($result)) {
</programlisting>
</example>
</para>
<note>
<para>
From 4.1.0, <parameter>row</parameter> became optional.
Calling <function>pg_fetch_assoc</function> will increment
the internal row counter by one.
</para>
</note>
<para>
See also
<function>pg_fetch_row</function>,

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.12 $ -->
<!-- $Revision: 1.13 $ -->
<!-- splitted from ./en/functions/pgsql.xml, last change in rev 1.2 -->
<refentry id="function.pg-fetch-object">
<refnamediv>
@ -38,9 +38,6 @@
insignificant).
</para>
<note>
<para>
From 4.1.0, <parameter>row</parameter> is optional.
</para>
<para>
From 4.3.0, <parameter>result_type</parameter> is default to PGSQL_ASSOC while
older versions' default was PGSQL_BOTH. There is no use for numeric property,
@ -88,7 +85,7 @@ pg_close($db_conn);
<para>
From 4.1.0, <parameter>row</parameter> became optional.
Calling <function>pg_fetch_object</function> will increment
internal row counter counter by 1.
the internal row counter counter by one.
</para>
</note>
<para>