mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Added samples
Added see also (mysql_info) git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@79289 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
e26c5431f0
commit
fe744b4f3e
1 changed files with 55 additions and 2 deletions
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue