georg Sun Apr 21 09:04:09 2002 EDT
Modified files:
/phpdoc/en/reference/mysql/functions mysql-affected-rows.xml
Log:
Added samples
Added see also (mysql_info)
Index: phpdoc/en/reference/mysql/functions/mysql-affected-rows.xml
diff -u phpdoc/en/reference/mysql/functions/mysql-affected-rows.xml:1.2
phpdoc/en/reference/mysql/functions/mysql-affected-rows.xml:1.3
--- phpdoc/en/reference/mysql/functions/mysql-affected-rows.xml:1.2 Wed Apr 17
02:41:04 2002
+++ phpdoc/en/reference/mysql/functions/mysql-affected-rows.xml Sun Apr 21 09:04:09
+2002
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/mysql.xml, last change in rev 1.2 -->
<refentry id="function.mysql-affected-rows">
<refnamediv>
@@ -51,9 +51,62 @@
</para>
<para>
If the last query failed, this function will return -1.
+ <example>
+ <title>Delete-Query</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+mysql_pconnect("localhost", "mysql_user", "mysql_password") or
+ die ("Could not connect");
+
+/* this should return the correct numbers of deleted records */
+mysql_query("DELETE FROM mytable WHERE id < 10");
+printf ("Records deleted: %d\n", mysql_affected_rows());
+
+/* without a where clause in a delete statement, it should return 0 */
+mysql_query("DELETE FROM mytable");
+printf ("Records deleted: %d\n", mysql_affected_rows());
+
+?>
+]]>
+ </programlisting>
+ <para>
+ The above example would produce the following output:
+ <screen>
+<![CDATA[
+Records deleted: 10
+Records deleted: 0
+]]>
+ </screen>
+ </para>
+ </example>
+ <example>
+ <title>Update-Query</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+mysql_pconnect("localhost", "mysql_user", "mysql_password") or
+ die ("Could not connect");
+
+mysql_query("UPDATE mytable SET used=1 WHERE id < 10");
+printf ("Updated records: %d\n", mysql_affected_rpws());
+mysql_query("COMMIT");
+?>
+]]>
+ </programlisting>
+ <para>
+ The above example would produce the following output:
+ <screen>
+<![CDATA[
+Updated Records: 10
+]]>
+ </screen>
+ </para>
+ </example>
</para>
<para>
- See also: <function>mysql_num_rows</function>.
+ See also: <function>mysql_num_rows</function>,
+ <function>mysql_info</function>.
</para>
</refsect1>
</refentry>