Add brief docs and example.

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@173160 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Dan Scott 2004-11-21 20:01:42 +00:00
parent 3ed020fe84
commit 1f25280a0f

View file

@ -1,11 +1,11 @@
<?xml version='1.0' encoding='iso-8859-1'?>
<!-- $Revision: 1.2 $ -->
<!-- $Revision: 1.3 $ -->
<!-- Generated by xml_proto.php v2.1. Found in /scripts directory of phpdoc. -->
<refentry id="function.PDOStatement-rowCount">
<refnamediv>
<refname>PDOStatement::rowCount</refname>
<refpurpose>
Returns the number of rows in a result set, or the number of rows affected by the last PDOStatement::execute()
Returns the number of rows affected by the last SQL statement
</refpurpose>
</refnamediv>
<refsect1>
@ -15,12 +15,33 @@
<void/>
</methodsynopsis>
&warn.undocumented.func;
<note>
<para>
Not always meaningful.
</para>
</note>
&warn.experimental.func;
<para>
<function>PDOStatement::rowCount</function> returns the number of
rows affected by the last DELETE, INSERT, or UPDATE statement
executed by the corresponding <literal>PDOStatement</literal> object.
</para>
<para>
If the last SQL statement executed by the associated
<literal>PDOStatement</literal> was a SELECT statement, some databases
may return the number of rows returned by that statement. However, this
behaviour is not guaranteed for all databases and should not be relied
on for portable applications.
</para>
<example><title>Return the number of deleted rows</title>
<programlisting role="php">
<![CDATA[
/* Delete all rows from the FRUIT table */
$del = $dbh->prepare('DELETE FROM fruit');
$del->execute();
/* Return number of rows that were deleted */
print("Return number of rows that were deleted:\n");
$count = $del->rowCount();
print("Deleted $count rows.\n");
]]>
</programlisting>
</example>
</refsect1>
</refentry>