选择语言 :

 Driver_Database_Driver_MySQL_Transaction::rollback

撤消事务,支持子事务

Bollean Driver_Database_Driver_MySQL_Transaction::rollback( )
返回值
  • Bollean true:成功;false:失败
File: ./drivers/database/mysql/transaction.class.php
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
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_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;
    }
}