PHP/PDO: use simple prepared statement with query return/affected rows?
问题 I am new to PDO objects and cannot find a single piece of documentation that will help me. Say I got a simple code to delete a row: $count = $dbh->exec("DELETE FROM fruit WHERE colour = 'red'"); That will return affected rows, but how would I use prepared statements with that? Can use use $dbh->prepare AND $dbh->exec or query !? 回答1: It should be the same as any other statement: $stmt = $dbh->prepare("DELETE FROM fruit WHERE colour = ?"); $stmt->execute(array('red')); $count = $stmt->rowCount