Using PDO / PHP and MySQL, how can I check if a record was inserted or updated when I use an INSERT ON DUPLICATE KEY UPDATE statement?
I have seen a solution using mysql_affected_rows() for PHP, but I am looking for a way I can use with PDO.
Using PDO / PHP and MySQL, how can I check if a record was inserted or updated when I use an INSERT ON DUPLICATE KEY UPDATE statement?
I have seen a solution using mysql_affected_rows() for PHP, but I am looking for a way I can use with PDO.
If you use PDO::exec() the return value will be 1 if the row has been inserted and 2 if the row has been updated.
If you're using a prepared statement and PDOStatement::execute() the same is true for PDOStement::rowCount()