选择语言 :

 Driver_Database_Driver_MySQLI_Transaction::rollback

撤消事务,支持子事务

Bollean Driver_Database_Driver_MySQLI_Transaction::rollback( )
返回值
  • Bollean true:成功;false:失败
File: ./drivers/database/mysqli/transaction.class.php
public 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_MySQLI_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;
    }
}