<?php
$pdo=new PDO('mysql:host=localhost;dbname=student','root','root');
try{
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$pdo->beginTransaction();
//第1条sql语句
$sqla="delete from chen where id=14";
$pdo->exec($sqla);
//第2天sql语句
$sqlb="delete froms chen where id=15"; //故意把from写错
$pdo->exec($sqlb);
}catch(Exception $e){
$pdo->rollBack();
$e->getMessage();
echo "操作失败";
}
?>