<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.maxdb-num-rows">
 <refnamediv>
  <refname>maxdb_num_rows</refname>
  <refname>maxdb::num_rows</refname>
  <refpurpose>Gets the number of rows in a result</refpurpose>
 </refnamediv>

 <refsect1 role="description">
  &reftitle.description;
  <para>&style.procedural;</para>
  <methodsynopsis>
   <type>int</type><methodname>maxdb_num_rows</methodname>
   <methodparam><type>resource</type><parameter>result</parameter></methodparam>
  </methodsynopsis>
  <para>&style.oop;</para>
  <fieldsynopsis><type>int</type><varname>maxdb->num_rows</varname></fieldsynopsis>
  <para>
   Returns the number of rows in the result set.
  </para>
  <para>
   The use of <function>maxdb_num_rows</function> depends on whether you use
   buffered or unbuffered result sets.
   In case you use unbuffered resultsets <function>maxdb_num_rows</function>
   will not correct the correct number of rows until all the rows in the result
   have been retrieved.
  </para>
 </refsect1>

 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>
   Returns number of rows in the result set.
  </para>
  <note>
   <para>
    If the number of rows is greater than maximal int value, the number
    will be returned as a string.
   </para>
  </note>
 </refsect1>

 <refsect1 role="examples">
  &reftitle.examples;
  <example>
   <title>&style.oop;</title>
   <programlisting role="php">
<![CDATA[
<?php
$maxdb = new maxdb("localhost", "MONA", "RED", "DEMODB");

/* check connection */
if (maxdb_connect_errno()) {
   printf("Connect failed: %s\n", maxdb_connect_error());
   exit();
}

if ($result = $maxdb->query("SELECT cno, name FROM hotel.customer ORDER BY name")) {

   /* determine number of rows result set */
   $row_cnt = $result->num_rows;

   printf("Result set has %d rows.\n", $row_cnt);

   /* close result set */
   $result->close();
}

/* close connection */
$maxdb->close();
?>
]]>
   </programlisting>
  </example>
  <example>
   <title>&style.procedural;</title>
   <programlisting role="php">
<![CDATA[
<?php
$link = maxdb_connect("localhost", "MONA", "RED", "DEMODB");

/* check connection */
if (maxdb_connect_errno()) {
   printf("Connect failed: %s\n", maxdb_connect_error());
   exit();
}

if ($result = maxdb_query($link, "SELECT cno, name FROM hotel.customer ORDER BY name")) {

   /* determine number of rows result set */
   $row_cnt = maxdb_num_rows($result);

   printf("Result set has %d rows.\n", $row_cnt);

   /* close result set */
   maxdb_free_result($result);
}

/* close connection */
maxdb_close($link);
?>
]]>
   </programlisting>
  </example>
  &example.outputs.similar;
  <screen>
<![CDATA[
Result set has 15 rows.
]]>
  </screen>
 </refsect1>

 <refsect1 role="seealso">
  &reftitle.seealso;
  <para>
   <simplelist>
    <member><function>maxdb_affected_rows</function></member>
    <member><function>maxdb_store_result</function></member>
    <member><function>maxdb_use_result</function></member>
    <member><function>maxdb_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:"~/.phpdoc/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
-->