mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Added mysql_fetch_assoc
(wondering why it wasn't documented ;-) git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@47894 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
8d0c00e348
commit
b3a19355d9
1 changed files with 60 additions and 1 deletions
|
@ -724,7 +724,66 @@ mysql_free_result ($result);
|
|||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<refentry id="function.mysql-fetch-field">
|
||||
<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>resource <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 equivalent 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"];
|
||||
}
|
||||
mysql_free_result ($result);
|
||||
?>
|
||||
</programlisting>
|
||||
</example>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<refentry id="function.mysql-fetch-field">
|
||||
<refnamediv>
|
||||
<refname>mysql_fetch_field</refname>
|
||||
<refpurpose>
|
||||
|
|
Loading…
Reference in a new issue