我对通过 php 脚本运行事务感到困惑。 在我的 MySql 中自动提交设置为 1, 然而当我运行一个脚本时
例如:mysql_query("开始交易");
$sql="INSERT INTO
`address`(`Address_Id`,
`Address_Line1`,
`Address_line2`,
`Zip`,
`Created_By`,
`Created_Date`,
`Updated_By`,
`Updated_Date`)
VALUES ('2','this is test1','test2','210','SYSTEM','NOW()','SYSTEM','NOW()')";
mysql_query($sql);
当我不给commit时,表中插入的记录为零。 只有当我发出提交命令时,记录才会出现。
另外请告诉我如果在 php 脚本中我开始事务然后不给出回滚或提交语句会发生什么
最佳答案
http://dev.mysql.com/doc/refman/5.5/en/commit.html :
By default, MySQL runs with autocommit mode enabled. This means that as soon as you execute a statement that updates (modifies) a table, MySQL stores the update on disk to make it permanent.
但是如果您明确指定 START TRANSACTION
- 那么它就不会被考虑在内,因此您在一个应该提交的事务中工作。
关于php - 事务 MySql 和 php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13287723/