Date: 09/28/00
- Next message: Ron Chmara: "[PHP-DOC] Security Perceptions: Re: [PHP-NOTES] note 8760 added to fopen"
- Previous message: Daniel Beckham: "[PHP-DOC] cvs: phpdoc /howto phpdoc-howto.xml"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
brianlmoon Thu Sep 28 12:27:37 2000 EDT
Modified files:
/phpdoc/en/functions mysql.xml
Log:
added docs for mysql_fetch_assoc
Index: phpdoc/en/functions/mysql.xml
diff -u phpdoc/en/functions/mysql.xml:1.26 phpdoc/en/functions/mysql.xml:1.27
--- phpdoc/en/functions/mysql.xml:1.26 Tue Sep 12 08:10:32 2000
+++ phpdoc/en/functions/mysql.xml Thu Sep 28 12:27:37 2000
@@ -593,7 +593,7 @@
<refnamediv>
<refname>mysql_fetch_array</refname>
<refpurpose>
- Fetch a result row as an associative array
+ Fetch a result row as an associative array, a numeric array, or both.
</refpurpose>
</refnamediv>
<refsect1>
@@ -643,15 +643,76 @@
</para>
<para>
For further details, see also
- <function>mysql_fetch_row</function>.
+ <function>mysql_fetch_row</function> and <function>mysql_fetch_assoc</function>.
</para>
<example>
<title><function>Mysql_fetch_array</function></title>
<programlisting role="php">
<?php
mysql_connect ($host, $user, $password);
-$result = mysql_db_query ("database","select * from table");
+$result = mysql_db_query ("database","select user_id, fullname from table");
while ($row = mysql_fetch_array ($result)) {
+ echo "user_id: ".$row["user_id"]."<br>\n";
+ echo "user_id: ".$row[0]."<br>\n";
+ echo "fullname: ".$row["fullname"]."<br>\n";
+ echo "fullname: ".$row[1]."<br>\n";
+}
+mysql_free_result ($result);
+?>
+ </programlisting>
+ </example>
+ </refsect1>
+ </refentry>
+
+ <refentry id="function.mysql-fetch-assoc">
+ <refnamediv>
+ <refname>mysql_fetch_assoc</refname>
+ <refpurpose>
+ Fetch a result row as an associative array
+ </refpurpose>
+ </refnamediv>
+ <refsect1>
+ <title>Description</title>
+ <funcsynopsis>
+ <funcprototype>
+ <funcdef>array <function>mysql_fetch_assoc</function></funcdef>
+ <paramdef>int <parameter>result</parameter></paramdef>
+ </funcprototype>
+ </funcsynopsis>
+ <para>
+ Returns an associative array that corresponds to the fetched row,
+ or false if there are no more rows.</para>
+ <para>
+ <function>mysql_fetch_assoc</function> is eqivilant to calling
+ <function>mysql_fetch_array</function> with MYSQL_ASSOC for the
+ optional second parameter. It only returns an associative array.
+ This is the way <function>mysql_fetch_array</function> originally
+ worked. If you need the numeric indices as well as the
+ associative, use <function>mysql_fetch_array</function>.
+ </para>
+ <para>
+ If two or more columns of the result have the same field names,
+ the last column will take precedence. To access the other column(s)
+ of the same name, you must use <function>mysql_fetch_array</function> and
+ have it return the numeric indices as well.
+ </para>
+ <para>
+ An important thing to note is that using
+ <function>mysql_fetch_assoc</function> is NOT significantly
+ slower than using <function>mysql_fetch_row</function>, while it
+ provides a significant added value.
+ </para>
+ <para>
+ For further details, see also
+ <function>mysql_fetch_row</function> and <function>mysql_fetch_array</function>.
+ </para>
+ <example>
+ <title><function>Mysql_fetch_assoc</function></title>
+ <programlisting role="php">
+<?php
+mysql_connect ($host, $user, $password);
+$result = mysql_db_query ("database","select * from table");
+while ($row = mysql_fetch_assoc ($result)) {
echo $row["user_id"];
echo $row["fullname"];
}
- Next message: Ron Chmara: "[PHP-DOC] Security Perceptions: Re: [PHP-NOTES] note 8760 added to fopen"
- Previous message: Daniel Beckham: "[PHP-DOC] cvs: phpdoc /howto phpdoc-howto.xml"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

