danbeck Thu Mar 8 13:56:37 2001 EDT
Modified files:
/phpdoc/en/functions mysql.xml
Log:
added errata clarification and clean up some function examples
Index: phpdoc/en/functions/mysql.xml
diff -u phpdoc/en/functions/mysql.xml:1.36 phpdoc/en/functions/mysql.xml:1.37
--- phpdoc/en/functions/mysql.xml:1.36 Thu Feb 15 16:15:33 2001
+++ phpdoc/en/functions/mysql.xml Thu Mar 8 13:56:37 2001
@@ -46,10 +46,11 @@
</funcprototype>
</funcsynopsis>
<para>
- <function>mysql_affected_rows</function> returns the number of
- rows affected by the last INSERT, UPDATE or DELETE query on the
- server associated with the specified link identifier. If the
- link identifier isn't specified, the last opened link is assumed.
+ <function>mysql_affected_rows</function> returns the number
+ of rows affected by the last INSERT, UPDATE or DELETE query
+ associated with <parameter>link_identifier</parameter>. If the
+ link identifier isn't specified, the last link opened by
+ <function>mysql_connect</function> is assumed.
</para>
<note>
<para>
@@ -63,14 +64,27 @@
of the records will have been deleted from the table but this
function will return zero.
</para>
+ <note>
+ <para>
+ When using UPDATE, MySQL will not update columns where the new
+ value is the same as the old value. This creates the possiblity
+ that <function>mysql_affected_rows</function> may not actually
+ equal the number of rows matched, only the number of rows that
+ were literally affected by the query.
+ </para>
+ </note>
<para>
- This command is not effective for SELECT statements, only on
- statements which modify records. To retrieve the number of rows
- returned from a SELECT, use <function>mysql_num_rows</function>.
+ <function>mysql_affected_rows</function> does not work with
+ SELECT statements; only on statements which modify records. To
+ retrieve the number of rows returned by a SELECT, use
+ <function>mysql_num_rows</function>.
</para>
<para>
If the last query failed, this function will return -1.
</para>
+ <para>
+ See also: <function>mysql_num_rows</function>.
+ </para>
</refsect1>
</refentry>
@@ -242,11 +256,13 @@
<title>MySQL connect example</title>
<programlisting role="php">
<?php
- $link = mysql_connect ("kraemer", "marliesle", "secret")
+
+ $link = mysql_connect ("localhost", "username", "secret")
or die ("Could not connect");
print ("Connected successfully");
mysql_close ($link);
-?>
+
+?>
</programlisting>
</example>
<para> See also
@@ -1533,29 +1549,30 @@
<function>mysql_num_rows</function> returns the number of rows in
a result set. This command is only valid for SELECT statements.
To retrieve the number of rows returned from a INSERT, UPDATE or
- DELETE, use <function>mysql_affected_rows</function>.
+ DELETE query, use <function>mysql_affected_rows</function>.
<example>
- <title>
- <function>
- mysql_num_rows example by [EMAIL PROTECTED]
- </function>
- </title>
+ <title><function>mysql_num_rows</function> example</title>
<programlisting role="php">
<?php
-$conn = mysql_connect("hostaddress", "username", "password");
-mysql_select_db("database",$conn); // needed if you have m,ultiple db's
-$Resultfornummembers = mysql_query("SELECT * FROM Accounts",$conn);
-$NumMembers = mysql_num_rows($Resultfornummembers);
-echo "$NumMembers Members";
-?>
+
+$link = mysql_connect("localhost", "username", "password");
+mysql_select_db("database", $link);
+
+$result = mysql_query("SELECT * FROM table1", $link);
+$num_rows = mysql_num_rows($result);
+
+echo "$num_rows Rows\n";
+
+?>
</programlisting>
</example>
</para>
<para>
See also:
- <function>mysql_db_query</function>,
- <function>mysql_query</function> and,
- <function>mysql_fetch_row</function>.
+ <function>mysql_affected_rows</function>,
+ <function>mysql_connect</function>,
+ <function>mysql_select_db</function> and
+ <function>mysql_query</function>.
</para>
<para>
For downward compatibility <function>mysql_numrows</function> can