PHP pdo 事務回滾代碼實例
$this->beginTransaction();
$this->exec('update people set age=2');
//$step1 = mysql教程_error();//你的類裡,改成如果執行sql錯誤,獲取錯誤代碼,相應的函數
$this->exec('INSERT INTO course (course,num) VALUES ("數學",100)');
//$step2 = mysql_error();
if (!$step1 && !$step2)
{
$this->commit();
}
else
{
$this->rollBack();
}