I have this query:
START TRANSACTION;
UPDATE users SET events = 0 WHERE id = 10;
UPDATE events SET seen = 1 WHERE author_id = 10 AND seen is NULL;
COMMIT;
When I execute that at PHPMyadmin, it works as well. but when I want to execute that by PHP:
$stm = $dbh->prepare("START TRANSACTION;
UPDATE users SET events = 0 WHERE id = ?;
UPDATE events SET seen = 1 WHERE author_id = ? AND seen is NULL;
COMMIT;");
$stm->execute(array($user_id, $user_id));
it throws an error:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UPDATE users SET events = 0 WHERE id = ?; UPDATE events SET seen = 1 ' at line 2' in C:\xampp\htdocs\myweb\really_test.php:306 Stack trace: #0 C:\xampp\htdocs\myweb\really_test.php(306): PDO->prepare('START TRANSACTI...') #1 {main} thrown in C:\xampp\htdocs\myweb\really_test.php on line 306
How can I fix it?