本文实例讲述了php事务回滚简单实现方法。分享给大家供大家参考,具体如下: $servername="localhost"; $username="root"; $password="admin"; $dbname="test"; try{ $conn=new PDO("mysql:host=$servername;dbname=$dbname",$username,$password); $conn->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION); //开始事务 $conn->beginTransaction(