事务提交
@return boolean
559115
public function trans_commit()
    {
        $this->conn('master'); //connect server
        $this->db->commit();
        $this->db->autocommit(true);
    }
1266924
public function rollback()
    {
        if ($this->_active && $this->_db->getActive()) {
            $this->_db->getPdoInstance()->rollBack();
            $this->_active = false;
        } else {
            throw new Exception('"Transaction"尚属未激活状态，不能执行"commit"和"rollback"操作', 101300602);
        }
    }
1163580
public function commit(): bool {
        if ($this->transactionExists) {
            $commited = $this->pdo->commit();
            $this->transactionExists = !$commited;
            return $commited;
        }
        return false;
    }
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;
	}
1242362
public function commit()
    {

        if (empty($this->body)) {
            return false;
        }

        $result = $this->query->connection->bulk($this->body);
        $this->operationCount = 0;
        $this->body = [];

        return $result;
    }
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;
    }
26283
public function check()
    {
        return true;//屏蔽校验功能
        $validate = new Validate($this->rule);
        if (!$validate->batch()->check($this->toArray()))
        { //当前VO字段不符合条件
            $this->error = $validate->getError();

            return false;
        }
        else if ($this->error)
        {//嵌套的VO字段不符合条件
            return false;
        }

        return true;
    }
709134
public function execute()
    {
        // If the jobset is finished or failed
        // the jobset may need to be dispatched
        // so we return true
        if ($this->isFinished() || $this->isFailed()) {
            return true;
        }
        // Just return false to tell to terminate the process
        if (!$this->isInTime()) {
            return false;
        }
        // return false means the jobset is done
        // and the process should be terminated
        if ($this->isDispatched() || $this->isCanceled()) {
            return false;
        }

        try {
            if (!$this->jobs) {
                $this->initJobs();
            }

            $this->doUnorderedJobs();
            $this->doOrderedJobs();

            $status = $this->getJobsetExecutionStatus();
            if ($status === JobsConst::JOB_SET_STATUS_FAILED) {
                $this->failed();
            } else {
                $this->updateStatus($status);
            }
        } catch (\Exception $e) {
            // just throw it
            throw $e;
        }

        return true;
    }
486789
public function close() : bool
    {
        foreach ($this->handlers as $handler) {
            if (method_exists($handler, 'close')) {
                $handler->close();
            }
        }
        return true;
    }
1355354
public function delete(): bool
    {
        if (! $this->exists())
        {
            return false;
        }

        $sql = 'DELETE FROM ' . $this->getTableName() . ' WHERE ' . $this->getKeyName() . ' = :key';
        $query = DB::getConnection()->prepare($sql);

        return $query->execute(['key' => $this->getKey()]);
    }
895736
protected function listenForEvents()
    {
        // -- Worker处理的事件
        //listener:beforeDaemonLoop
        //listener:beforeGetJob
        //listener:afterGetJob
        //listener:beforeJobHandle
        //listener:logger
        //listener:afterJobHandle
        //listener:jobException
        //listener:jobFailed
        //listener:afterDaemonLoop
        //listener:stop
        $this->eventsManager->attach('listener', function (Event $event, $source, $data) {
            $date = date('Y-m-d H:i:s');
            $class = get_class($source);
            $event = $event->getType();
            $payload = '';
            $message = '';
            if (is_array($data)) {
                $job = $data[0];
                $e = $data[1];
                if ($job instanceof Job) {
                    $payload = $job->getPayload();
                } elseif (is_scalar($data)) {
                    $payload = $data;
                } else {
                    $payload = serialize($job);
                }
                if ($e instanceof \Exception) {
                    $message = $data[1]->getMessage();
                } else {
                    $message = serialize($job);
                }
            } else {
                if ($data instanceof Job) {
                    $payload = $data->getPayload();
                } elseif (is_scalar($data)) {
                    $message = $data;
                } else {
                    $message = serialize($data);
                }
            }
            $this->line('[' . $date . '] Event=listener:' . $event . ', Class=' . $class . ', Msg=' . $message . ', Payload=' . $payload);
        });
    }
676458
public function work()
    {
        if (!$this->connect()) {
            $this->logger()->alert(sprintf('Worker unable to connect, exiting'));
            $this->dispatchEvent('Worker.job.connectionFailed');

            return false;
        }

        $jobClass = $this->engine->getJobClass();
        $time = microtime(true);
        while ($this->running) {
            if (is_int($this->maxRuntime) && $this->runtime >= $this->maxRuntime) {
                $this->logger()->debug('Max runtime reached, exiting');
                $this->dispatchEvent('Worker.maxRuntime');
                break;
            } elseif (is_int($this->maxIterations) && $this->iterations >= $this->maxIterations) {
                $this->logger()->debug('Max iterations reached, exiting');
                $this->dispatchEvent('Worker.maxIterations');
                break;
            }

            $this->runtime += microtime(true) - $time;
            $time = microtime(true);
            $this->iterations++;
            $item = $this->engine->pop($this->queue);
            $this->dispatchEvent('Worker.job.seen', ['item' => $item]);
            if (empty($item)) {
                $this->dispatchEvent('Worker.job.empty');
                sleep($this->interval);
                continue;
            }

            $success = false;
            $job = new $jobClass($item, $this->engine);
            if (!is_callable($item['class'])) {
                $this->logger()->alert('Invalid callable for job. Rejecting job from queue.');
                $job->reject();
                $this->dispatchEvent('Worker.job.invalid', ['job' => $job]);
                continue;
            }

            $this->dispatchEvent('Worker.job.start', ['job' => $job]);

            try {
                $success = $this->perform($item, $job);
            } catch (Exception $e) {
                $this->dispatchEvent('Worker.job.exception', [
                    'job' => $job,
                    'exception' => $e,
                ]);
            }

            if ($success) {
                $job->acknowledge();
                $this->dispatchEvent('Worker.job.success', ['job' => $job]);
                continue;
            }

            $this->logger()->info('Failed. Releasing job to queue');
            $job->release();
            $this->dispatchEvent('Worker.job.failure', ['job' => $job]);
        }

        return true;
    }
349454
public function stop()
    {
        // 如果有设置进程终止回调，则执行
        if($this->onWorkerStop)
        {
            call_user_func($this->onWorkerStop, $this);
        }
        // 删除相关监听事件，关闭_mainSocket
        static::$globalEvent->del($this->_mainSocket, EventInterface::EV_READ);
        @fclose($this->_mainSocket);
    }
664684
public function commitTransaction(): bool
	{
		if($this->transactionNestingLevel > 0 && --$this->transactionNestingLevel === 0)
		{
			return $this->pdo->commit();
		}

		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);
        }
    }
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;
    }
256351
public function close()
    {
        $this->handlerLock = true;

        while (count($this->handlers) > 0) {
            array_pop($this->handlers);
            $this->stacks['delete']->pop();
            $this->stacks['clean']->pop();
            $this->stacks['create']->pop();
            $this->stacks['read']->pop();
            $this->stacks['write']->pop();
        }

        $this->handlerLock = false;
        return true;
    }