I'm running multiple queries using PDO. If the second query fails, no Exception is thrown.
$db = new PDO("mysql:host=localhost;dbname=test", 'root', '');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "
DELETE FROM car;
INSERT INTO car(name, type) SELECT name, from FROM vehicle;
";
try {
$db->exec($sql);
}
catch (PDOException $e)
{
echo $e->getMessage();
die();
}
The above code executes without throwing an exception.
How can I make sure that all queries have run successfully? How can I check which queries have failed?
P.S. I'm using PDO multi query to run MySQL dumps, but any valid .sql file should work.