Home >php教程 >php手册 >adodb的事务处理咋没效果

adodb的事务处理咋没效果

WBOY
WBOYOriginal
2016-05-25 16:53:241272browse

问题:adodb的事务处理为什么没效果?

解决方法:数据表都是InnoDB类型的,看下面的代码,第二条sql语句是错的,第一条语句却执行了

<?php
include dirname(__FILE__).&#39;adodbadodb.inc.php&#39;; 
include dirname(__FILE__).&#39;bbsconfig.inc.php&#39;; 
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; 
$db = &ADONewConnection(&#39;mysql&#39;); 
$db->Connect($dbhost, $dbuser, $dbpw, $dbname); 
$db->debug=1; 
$db->StartTrans(); 
$db->Execute("update table1 set fieldid=fieldid+1");  
$db->Execute("update table2 set joinid1=joinid+1 where id=11"); 
$db->CompleteTrans(); 
?>

执行后的结果:第一条sql语句执行,第二条sql语句不执行。这里根本没有起到事务的效果。

网上讨论比较多的是:
 

$db = &ADONewConnection(&#39;mysql&#39;); 
改成$db = &ADONewConnection(&#39;mysqlt&#39;);或者$db = &ADONewConnection(&#39;mysqli&#39;);

可是改了还是不行,网友建意:

$db = &ADONewConnection(&#39;mysql&#39;); 
$db->Connect($dbhost, $dbuser, $dbpw, $dbname);

永久地址:

转载随意~请带上教程地址吧^^

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn