December 5th, 2013, 06:36 PM
PDO equivalent for mysqli_info() ?
Is there an equivalent to mysqli_info() for use with PDO Statements?
Right now, I'm using this to determine if any rows were affected during an UPDATE:
However, in my case, there are two different situations where an UPDATE might return "0" from rowCount(). 1. If a record wasn't found or 2. If a record was found, but an update didn't happen because the column being updated already contained the same information.
$count = $STMT->rowCount();
With mysqli_info() I could differentiate between those two "zero rows affected" situations. How can I do this using PDO Statements?
December 5th, 2013, 09:24 PM
as far as I can tell, it's either-or. By default, rowCount() will return the number of changed rows. Alternatively, you can set PDO::MYSQL_ATTR_FOUND_ROWS to make the method return the number of found rows instead. But I haven't found a way to get both.
Note that the differentiation between matched and changed rows seems to be a MySQL quirk. Since PDO is a generalized database extension, it may not support every special feature of every database system. If you want to write your code exclusively for MySQL, then MySQLi is the better choice.
What do you need this for, by the way?
December 6th, 2013, 06:15 PM