我需要确保以下各项在PDO Transactions中能正常工作:
// Database Transaction
try
{
// Start the transaction.
$db->beginTransaction();
// Some method in this class which runs a database query
$this->do_something($data);
// Another method doing multiple database queries
$this->do_another_thing($other_data);
// Directly doing some query
$stmt = $db->prepare("DELETE FROM `table` WHERE `time` < DATE_SUB(NOW(), INTERVAL :days DAY)");
$stmt->execute(['days' => 2]);
// Commit
$db->commit();
}
catch(Exception $e)
{
$error = $e->getMessage();
// log
// Rollback the transaction.
$db->rollBack();
}
我的问题是:
它会以这种方式回滚所有内容(包括以其他方法完成的查询)吗?或仅直接查询?