note 32357 deleted from function.mysql-query by didou
| From: | didou@php.net | Date: | Sat, 16 Aug 2003 09:27:40 +0000 |
| Subject: | note 32357 deleted from function.mysql-query by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-54304@lists.php.net to get a copy of this message | ||
Note Submitter: gwaddell@gwaddell.com
----
Pete Kelly, there is a reason the second example for UPDATE is slower from your code. It is working
across all rows to perform the UPDATE. Your Example 1 only changes 1 row.
if($row = mysql_fetch_array($rs))
{
mysql_query("UPDATE users SET visits=visits+1 WHERE id =
'".$row["id"]."'");
}
would have to change to a while loop to be an equal test:
while( $row = mysql_fetch_array( $rs ) )
{
mysql_query( "UPDATE users SET visits=visits+1 WHERE id =
'".$row["id"]."'" );
}
(test for no rows returned .: do an INSERT, is not shown)
Graham Waddell