php-doc-en/reference/cubrid/functions/cubrid-num-rows.xml

121 lines
3.1 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.cubrid-num-rows" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>cubrid_num_rows</refname>
<refpurpose>Get the number of rows in the result set</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>int</type><methodname>cubrid_num_rows</methodname>
<methodparam><type>resource</type><parameter>result</parameter></methodparam>
</methodsynopsis>
<para>
The <function>cubrid_num_rows</function> function is used to get the
number of rows from the query result. You can use it only when the query
executed is a select statement. When you want to know such value for
INSERT, UPDATE, or DELETE query, you have to use the
<function>cubrid_affected_rows</function> function.
</para>
<para>
Note: The <function>cubrid_num_rows</function> function can only be used
for synchronous query; it returns 0 when it is used for asynchronous query.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>result</parameter></term>
<listitem><para><parameter>result</parameter> comes from a call to
<function>cubrid_execute</function>, <function>cubrid_query</function> and
<function>cubrid_prepare</function></para></listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Number of rows, when process is successful.
</para>
<para>
0 when the query was done in async mode.
</para>
<para>
-1, if SQL statement is not SELECT.
</para>
<para>
&false; when process is unsuccessful.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<example>
<title><function>cubrid_num_rows</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$conn = cubrid_connect("localhost", 33000, "demodb", "dba");
$req = cubrid_execute($conn, "SELECT * FROM code");
$row_num = cubrid_num_rows($req);
$col_num = cubrid_num_cols($req);
printf("Row Num: %d\nColumn Num: %d\n", $row_num, $col_num);
cubrid_disconnect($conn);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Row Num: 6
Column Num: 2
]]>
</screen>
</example>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>cubrid_execute</function></member>
<member><function>cubrid_num_cols</function></member>
<member><function>cubrid_affected_rows</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
-->