提交事务,支持子事务
Boolean Driver_Database_Driver_MySQLI_Transaction::commit( )
Boolean
true:成功public function commit()
{
if (!$this->id || ! $this->_haveid()) return false;
if ($this->is_root())
{
# 父事务
while (count(Database_Driver_MySQLI_Transaction::$transactions[$this->_connection_id]) > 1)
{
# 还有没有提交的子事务
end(Database_Driver_MySQLI_Transaction::$transactions[$this->_connection_id]);
$subid = key(Database_Driver_MySQLI_Transaction::$transactions[$this->_connection_id]);
if (!$this->_release_save_point($subid))
{
throw new Exception('commit error');
}
}
$status = $this->_query('COMMIT;');
$this->_query('SET AUTOCOMMIT=1;');
if ($status) unset(Database_Driver_MySQLI_Transaction::$transactions[$this->_connection_id]);
}
else
{
# 子事务
$status = $this->_release_save_point($this->id);
}
if ($status)
{
$this->id = null;
return true;
}
else
{
throw new Exception('not commit transaction');
}
}