php adodb transaction code example
Example: php adodb transaction
/*
* Start transaction scope
*/
$conn->beginTrans();
/*
* Execute some insert or update SQL
*/
$ok = $conn->execute($sql);
if ($ok) {
/*
* The previous execution succeeded, do some more
*/
$ok = $conn->execute($sql2);
} else {
/*
* Branch, do some other work, then return
*/
}
if (!$ok) {
/*
* Test the last insertion, if not successful roll
* back the entire transaction scope
*/
$conn->rollbackTrans();
} else {
/*
* Go ahead and commit
*/
$conn->commitTrans();
}