撤消事务,支持子事务
Bollean Driver_Database_Driver_MySQL_Transaction::rollback( )
Bollean
true:成功;false:失败
123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152public
function
rollback()
{
if
(!
$this
->id)
return
false;
if
(!
$this
->_haveid())
return
false;
if
(
$this
->is_root())
{
//父事务
$status
=
$this
->_query(
'ROLLBACK;'
);
$this
->_query(
'SET AUTOCOMMIT=1;'
);
if
(
$status
)
{
unset(Database_Driver_MySQL_Transaction::
$transactions
[
$this
->_connection_id]);
}
}
else
{
//子事务
$status
=
$this
->_query(
"ROLLBACK TO SAVEPOINT {$this->id};"
);
$this
->_release_save_point(
$this
->id);
}
if
(
$status
)
{
$this
->id = null;
return
true;
}
else
{
return
false;
}
}