启动一个事务
@return boolean
979400
public function beginTransaction(): bool
    {
        if(!$this->inTransaction())
        {
            $generator = $this->__beginTransaction();
            if(!$generator->valid())
            {
                return $generator->getReturn();
            }
            $current = $generator->current();
            $generator->next();
            $generator->send($current);
            $result = $generator->getReturn();
            if(!$result)
            {
                return $result;
            }
        }
        $this->exec('SAVEPOINT P' . $this->getTransactionLevels());
        $this->__tBeginTransaction();
        return true;
    }
526644
final public function commit()
    {
        if (!$this->pdo) {
            throw  new Exception('您还没有连接数据库', Exception::CODE_DATABASE_ERROR);
        }
        $this->_begintransaction = false;
        return $this->pdo->commit();
    }
285489
public function rollback() {

        if($this->transactionCounter > 0) {
            $this->transactionCounter = 0;
            return parent::rollback();
        }//if

        $this->transactionCounter = 0;
        return false;

    }
1208054
public function rollbackTransaction(): bool
    {
        --$this->transactionLevel;

        if ($this->transactionLevel == 0) {
            $this->isProfiling() && $this->getLogger()->info('Rollback transaction');

            try {
                return $this->getPDO()->rollBack();
            } catch (\PDOException $e) {
                throw $this->mapException($e, "ROLLBACK TRANSACTION");
            }
        }

        $this->savepointRollback($this->transactionLevel + 1);

        return true;
    }
923798
public function start()
    {
        if ($this->started) {
            return true;
        }
        
        // start the session
        if (session_status() == PHP_SESSION_NONE) {
            
            $this->init();
            
            // not native
            if ($this->handler) {
                $this->handler->register();
            }
            // 将 session_write_close() 函数注册为关闭会话的函数。
            //@session_register_shutdown();
            //register_shutdown_function('session_write_close');
            
            $res = session_start();
            
            // 将Collection的data绑定到 $_SESSION
            $this->data = & $_SESSION;
            $this->started = true;
            
            if (static::getStorage()) {
                $key = static::getSessionKey();
                $sdata = static::getStorage()->get($key);
                if ($this->data && !$sdata) {
                    foreach ($_SESSION as $k => $v) {
                        $_SESSION[$k] = $v;
                    }
                }
                \Wslim\Ioc::logger('session')->debug(sprintf('[%s]start: %s storage: %s', static::getId(), json_encode($this->data), json_encode($sdata)));
            }
        }
        
        return true;
    }
34688
public function current() {

        if (!$this->recordset->valid()) {
            return false;
        }

        if (!$record = $this->recordset->current()) {
            return false;
        }

        // Apply callback and return.
        if (!is_null($this->callbackextra)) {
            return call_user_func($this->callback, $record, $this->callbackextra);
        } else {
            return call_user_func($this->callback, $record);
        }
    }
24431
public function startTrans()
    {
        $this->initConnect(true);
        if (!$this->linkID) {
            return false;
        }

        ++$this->transTimes;
        try {
            if (1 == $this->transTimes) {
                $this->linkID->beginTransaction();
            } elseif ($this->transTimes > 1 && $this->supportSavepoint()) {
                $this->linkID->exec(
                    $this->parseSavepoint('trans' . $this->transTimes)
                );
            }

        } catch (\PDOException $e) {
            if ($this->isBreak($e)) {
                return $this->close()->startTrans();
            }
            throw $e;
        } catch (\Exception $e) {
            if ($this->isBreak($e)) {
                return $this->close()->startTrans();
            }
            throw $e;
        }
        return null;
    }
920947
public function rollback(): bool {
        if ($this->transactionExists) {
            $rolledBack = $this->pdo->rollBack();
            $this->transactionExists = !$rolledBack;
            return $rolledBack;
        }
        return false;
    }
163784
public function forupdate() {
        try {
            $this->checkDialect();
        } catch (DialectException $e) {
            return false;
        }
        // 不在事务中锁定失败.
        if (!$this->dialect->inTransaction()) {
            return false;
        }
        $this->forupdate = true;
        $data            = $this->get();
        // 成功
        if ($data) {
            return $data;
        }

        return false;
    }
536139
public function commit(): bool
    {
        $this->__tCommit();
        $generator = $this->__commit();
        if(!$generator->valid())
        {
            return $generator->getReturn();
        }
        $current = $generator->current();
        $generator->next();
        $generator->send($current);
        return $generator->getReturn();
    }
1254054
public function touch(): bool
	{
		if($this->isPersisted)
		{
			$this->columns[$this->getUpdatedAtColumn()] = null;

			return $this->save();
		}

		return false;
	}
1311193
public function run()
    {
        if (!$this->validate()) {
            return false;
        }

        return DB::transaction(function() {
            $events = $this->getDeferedEvents();

            foreach ($events as $event) {
                if (!empty($event->value)) {
                    continue;
                }

                $event->value = Event::fire($event->name);
                $event->save();
            }
        });
    }
433333
public function isFromKeyword()
    {
        // 未加载,说明未匹配到任何关键字
        if (!$this->loaded) {
            return false;
        }

        // 已加载,但id为空,说明未匹配到任何关键字
        if ($this->loaded && !$this['id']) {
            return false;
        }

        // 如果是默认回复,说明未匹配到任何关键字
        if ($this['id'] == 'default') {
            return false;
        }

        return true;
    }
1163580
public function commit(): bool {
        if ($this->transactionExists) {
            $commited = $this->pdo->commit();
            $this->transactionExists = !$commited;
            return $commited;
        }
        return false;
    }
285053
public function flush() {
        // 缓存不存在则查询数据表信息
        $this->db->setModel($this->name);
        $fields =   $this->db->getFields($this->getTableName());
        if(!$fields) { // 无法获取字段信息
            return false;
        }
        $this->fields   =   array_keys($fields);
        unset($this->fields['_pk']);
        foreach ($fields as $key=>$val){
            // 记录字段类型
            $type[$key]     =   $val['type'];
            if($val['primary']) {
                  // 增加复合主键支持
                if (isset($this->fields['_pk']) && $this->fields['_pk'] != null) {
                    if (is_string($this->fields['_pk'])) {
                        $this->pk   =   array($this->fields['_pk']);
                        $this->fields['_pk']   =   $this->pk;
                    }
                    $this->pk[]   =   $key;
                    $this->fields['_pk'][]   =   $key;
                } else {
                    $this->pk   =   $key;
                    $this->fields['_pk']   =   $key;
                }
                if($val['autoinc']) $this->autoinc   =   true;
            }
        }
        // 记录字段类型信息
        $this->fields['_type'] =  $type;

        // 2008-3-7 增加缓存开关控制
        if(C('DB_FIELDS_CACHE')){
            // 永久缓存数据表信息
            $db   =  $this->dbName?:C('DB_NAME');
            F('_fields/'.strtolower($db.'.'.$this->tablePrefix.$this->name),$this->fields);
        }
    }
554438
public function disconnect()
    {
        if (!is_resource($this->connection)) {
            $this->connected = false;

            return true;
        }
        $this->connected = !fclose($this->connection);

        if (!$this->connected) {
            $this->connection = null;
        }

        return !$this->connected;
    }
989864
public function disconnect()
	{
		if( $this->xmpp )
		{
			if( $this->printLog )
				echo $this->xmpp->log->printout();
			$this->xmpp->disconnect();
			$this->xmpp = NULL;
			return TRUE;
		}
		return FALSE;
	}