<?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.14 $ --> <refentry id="function.mysql-fetch-object"> <refnamediv> <refname>mysql_fetch_object</refname> <refpurpose>Fetch a result row as an object</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>object</type><methodname>mysql_fetch_object</methodname> <methodparam><type>resource</type><parameter>result</parameter></methodparam> </methodsynopsis> <para> Returns an object with properties that correspond to the fetched row and moves the internal data pointer ahead. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> &mysql.result.description; </variablelist> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> Returns an <type>object</type> with properties that correspond to the fetched row, or &false; if there are no more rows. </para> <para> <function>mysql_fetch_row</function> fetches one row of data from the result associated with the specified result identifier. The row is returned as an array. Each result column is stored in an array offset, starting at offset 0. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title><function>mysql_fetch_object</function> example</title> <programlisting role="php"> <![CDATA[ <?php mysql_connect("hostname", "user", "password"); mysql_select_db("mydb"); $result = mysql_query("select * from mytable"); while ($row = mysql_fetch_object($result)) { echo $row->user_id; echo $row->fullname; } mysql_free_result($result); ?> ]]> </programlisting> </example> </para> <para> <example> <title><function>mysql_fetch_object</function> example</title> <programlisting role="php"> <![CDATA[ <?php $row = mysql_fetch_object($result); /* this is valid */ echo $row->field; /* this is invalid */ // echo $row->0; ?> ]]> </programlisting> </example> </para> </refsect1> <refsect1 role="notes"> &reftitle.notes; <note> <title>Performance</title> <para> Speed-wise, the function is identical to <function>mysql_fetch_array</function>, and almost as quick as <function>mysql_fetch_row</function> (the difference is insignificant). </para> </note> <note> <para> <function>mysql_fetch_object</function> is similar to <function>mysql_fetch_array</function>, with one difference - an object is returned, instead of an array. Indirectly, that means that you can only access the data by the field names, and not by their offsets (numbers are illegal property names). </para> </note> &database.field-case; &database.fetch-null; </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>mysql_fetch_array</function></member> <member><function>mysql_fetch_assoc</function></member> <member><function>mysql_fetch_row</function></member> <member><function>mysql_data_seek</function></member> <member><function>mysql_query</function></member> </simplelist> </para> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->