Home >Backend Development >PHP Tutorial >Why does adodb transaction processing not work_PHP tutorial
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);