Problem with BDB ,can anybody help me!!!
| From: | marcos at arnal dot es | Date: | Mon, 23 Jul 2001 10:43:36 +0000 |
| Subject: | Problem with BDB ,can anybody help me!!! | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-10659@lists.php.net to get a copy of this message | ||
I have a Linux Server, with Apache 1.3.19 + PHP 4.0.6 and MySQL 3.23.37, and
i have a trouble with Transactions in PHP code:
When i write a transaction, and some error (PHP lang error) occurs, the
transaction are autocommited, and only part of the querys are made, with the
inconsistence of data, that this make, here a example of my problem:
.
.
.
// Start transaction
$q = "BEGIN WORK"
$db->query($q);
if( $db->errno) {
echo "Can't start transaction.";
return;
}
$q = "UPDATE ....";
$db->query($q);
if( $db->errno) {
echo "Error.";
$db->query( "ROLLBACK");
return;
}
$q = "DELETE ....";
$db->query($q);
if( $db->errno) {
echo "Error.";
$db->query( "ROLLBACK");
return;
}
// Here a error halts the code
exit; // halt by hand
// Some other querys
$q = "DELETE ....";
$db->query($q);
if( $db->errno) {
echo "Error.";
$db->query( "ROLLBACK");
return;
}
$db->query("COMMIT");
In this example the $db->query("COMMIT"); command are never executed, and
the 2 first querys are executed, and the last and never executed.
How i can solve this??
Can anybody help me!!