$con=mysqli_connect("localhost","wrong_user","my_password","my_db");
if (!$con)
{
die("连接错误: " . mysqli_connect_error());
}
mysqli_autocommit($conn,false);//表示事务开始
mysqli_query();//操作insert,update,delete
if(ture)
{
mysqli_commit($conn); //成功即提交
}else
{
mysqli_rollback($conn);//失败进行回滚到事务开始点
}