mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 17:08:54 +00:00
added errata clarification and clean up some function examples
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@43031 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
79add51c1b
commit
234a88d800
1 changed files with 41 additions and 24 deletions
|
@ -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 @@ field3
|
|||
<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 crubel@trilizio.org
|
||||
</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
|
||||
|
|
Loading…
Reference in a new issue