需要执行一组 PDO MYSQl 查询,以防我的事务开始后出现任何故障 Unable to catch any exception 。即使我给表名错误。例如
class user extends PDO
{
function empid()
{
$dbh->beginTransaction();
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION)
try
{
$update= "update user set data=1 where user_id = 11";
$update_pre = $dbh->prepare($update);
$code_pre->execute();
$insert="insert into user set user name="jesi",age='22';
$insert_pre = $dbh->prepare($insert);
$insert_pre->execute();
dbh->commit
}
catch(Exception $e)
{
$dbh->rollBack();
file_put_contents('mylog.txt', $e->getMessage(), FILE_APPEND);
}
}
}
有任何想法吗 ???