Home  >  Article  >  Backend Development  >  Why does adodb transaction processing not work_PHP tutorial

Why does adodb transaction processing not work_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:52:04966browse



Question
Why does adodb transaction processing not work?
Solution
The data tables are all of InnoDB type. Look at the code below. The second sql statement is wrong, but the first statement is executed

include dirname(__FILE__).'adodbadodb.inc.php';
include dirname(__FILE__).'bbsconfig.inc.php';
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
$db = &ADONewConnection('mysql');
$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();
?>
Result after execution: The first sql statement is executed, but the second sql statement is not executed. There is no transactional effect here at all.

I saw it online
$db = &ADONewConnection('mysql');
Change to $db = &ADONewConnection('mysqlt'); or $db = &ADONewConnection('mysqli');
But it still doesn't work after changing it.

Hope you all
Let’s discuss it. . .


Netizens’ suggestions:
$db = &ADONewConnection('mysql');
$db->Connect($dbhost, $dbuser, $dbpw, $dbname);

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632518.htmlTechArticleProblem: Adodb transaction processing is not effective? Solution: The data tables are all of InnoDB type. See the code below. The second sql statement is wrong, but the first statement executes include dirname(...
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