In MySql, how can I get the count of all affected rows when executing multiple queries simultaneously?
I currently do like this:
$stmt = ' update prodb set buyer = buyer+1 where userId = 1; update prodb set seller = seller+1 where userId = 2; '; $update = $dbc->prepare($stmt); $update->execute(); $queryCount = $update->rowCount(); echo 'This is QueryCount '.$queryCount; But, even though there are 2 rows being affected, I get $queryCount as only 1. Is there a way to get the query count as 2. i.e the count of first statement, and the count of the second one? I can confirm that there are two rows being affected here.
I'm doing all this using MySql PDO.
rowCount()only gets the results of the LAST query you execute. if you execute two queries, whichever of those finishes last will be the one rowCount() reports on. rowCount() is essentially just calling themysql_affected_rows()api function.