表的类型首先要是InnoDB
<?php $db_connect = mysql_connect( 'localhost' , 'root' , '' ); mysql_select_db( 'gmmenager' ,$db_connect); mysql_query( "BEGIN" ); $sql = "insert into user (name,password) values (1111,1111);" ; $sql2 = "insert into user (name,password) values (1111,1111);" ; $res = mysql_query($sql); $res1 = mysql_query($sql2); if ($res && $res1){ mysql_query( "COMMIT" ); echo '提交成功。' ; } else { mysql_query( "ROLLBACK" ); echo '数据回滚。' ; } mysql_query( "END" ); ?> |