The actual column names are account and passwd so the second query will failed, but the first query still inserted into database.
$sql1 = "INSERT INTO users (account, passwd) VALUES ('account+1', 'password+1')";
$sql2 = "INSERT INTO users (account, password) VALUES ('account+2', 'password+2')";
try {
$db->beginTransaction();
$db->query($sql1);
$db->query($sql2);
$db->commit();
} catch (Exception $e) {
$db->rollback();
die($e->getMessage());
}
The transaction started successfully with no errors, the problem is that it doesn’t rollback, always rows are inserted regardless of failing queries.
MySQL version 5.5.25 and table type is InnoDB.
Did you turn on exceptions? By default pdo doesn’t throw them and silently ignores errors.