顺便说一句adodb操作事务是有点题的,用不了的.
我的代码:
mysql_query("BEGIN");
$ok1 = $db->Execute($sql1);
$ok2 = $db->Execute($sql2);
$ok3 = $db->Execute($sql3);
if($ok1 && $ok2 && $ok3){
$Message->warning("审核成功,请返回!","index.php?mod=message&op=appfull");
mysql_query("COMMIT");
exit;
} else{
$Message->warning("审核失败,请返回!","index.php?mod=message&op=appfull");
mysql_query("ROLLBACK");
exit;
}
这段代码怎么不起作用呢?
表都是InnoDB.
我的代码:
mysql_query("BEGIN");
$ok1 = $db->Execute($sql1);
$ok2 = $db->Execute($sql2);
$ok3 = $db->Execute($sql3);
if($ok1 && $ok2 && $ok3){
$Message->warning("审核成功,请返回!","index.php?mod=message&op=appfull");
mysql_query("COMMIT");
exit;
} else{
$Message->warning("审核失败,请返回!","index.php?mod=message&op=appfull");
mysql_query("ROLLBACK");
exit;
}
这段代码怎么不起作用呢?
表都是InnoDB.
autocommit 是不是 On 了,这样就会在每句自动commit了
用show命令检查一下,
mysql> show variables like 'autocommit';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| autocommit | ON |
+---------------+-------+
1 row in set (0.00 sec)
set @@autocommit=off;把它关了就行了。
update users set messagenum=messagenum+15000 where id=175
insert into credits(parentid,userid,messagenum,flag,auditname,types,info,handler)values(99999,175,15000,1,'color',0,null,'')
update appmsgcredits set isaudit=1 where id=50
1楼的 show variables like 'autocommit';
这条语句执行不了的.
你在什么中执行?
如果不行,你就直接看一下你的mysql的配置选项文件 my.ini 或 my.cnf 中的关于这个变量的设置。
$Message->warning("审核失败,请返回!","index.php?mod=message&op=appfull");
mysql_query("ROLLBACK");