Re: Retrieving rows matched when using UPDATE in PHP/MySQL

From: Date: Sat, 24 Nov 2001 13:16:32 +0000
Subject: Re: Retrieving rows matched when using UPDATE in PHP/MySQL
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-14569@lists.php.net to get a copy of this message
> When I manually do an update using MySQL I get extended query result like > "Rows matched", "ChangeD" and "Warnings". See example below: > " > UPDATE Foo SET bar = 'value' WHERE ID = 666; > Query OK, 0 rows affected (0.00 sec) > Rows matched: 1 Changed: 0 Warnings: 0 > " > How do I retrieve these values using PHP and the MySQL lib? (I'm especially > interested in the "Rows matched" value since the Rows affected function > isn't enough to determine why an update resulted in 0 rows changed). John, It is common practice to check the db BEFORE performing the UPDATE. You want to do it afterwards... Hey it takes all sorts right!? Issue a "SELECT * FROM tables WHERE clause" instruction. Limit the columns retrieved instead of using *, if you prefer; substitute your UPDATE's "Foo" into the "tables" clause; replace the WHERE clause with the UPDATE's WHERE clause. That answers you Q in a MySQL sense - I assume can you handle the PHP from here? =dn

« previous php.db (#14569) next »