src/db/BuildSql.php
public function query($sql = '')
    {

        // 存入Sql Explain信息
        if (!empty($this->config['sql_explain'])) {
            $res = $this->link->query('explain ' . $this->bulid['sql']);
            if ($res) {
                $this->sqlInfo['explain'] = $res->fetchAll(PDO::FETCH_ASSOC);
            }
        }

        $_beginTime = microtime(true);
        $result     = $this->link->query($this->bulid['sql']);
        $_endTime   = microtime(true);

        $this->sqlInfo['time'] = $_endTime - $_beginTime; // 获取执行时间
        $this->sqlInfo['sql']  = $this->bulid['sql'];

        // 执行成功
        if ($result) {

            // 存入调试信息中
            Trace::addSqlInfo($this->sqlInfo);
            // 存入文件中
            if ($this->config['save_log']) {
                $this->addSqlLog();
            }

            return $result;
        } else {
            // 存入文件
            if ($this->config['error_log']) {
                $this->addErrorSqlLog();
            }

            if (config('debug')) {
                throw new Exception('SQL ERROR : ' . $this->bulid['sql']);
            }

            if (config('trace')) {
                Trace::addErrorInfo('[SQL ERROR] ' . $this->bulid['sql']);
            }

            return false;

        }

    }
public function query($sql = '')
    {

        // 存入Sql Explain信息
        if (!empty($this->config['sql_explain'])) {
            $res = $this->link->query('explain ' . $this->bulid['sql']);
            if ($res) {
                $this->sqlInfo['explain'] = $res->fetchAll(PDO::FETCH_ASSOC);
            }
        }

        $_beginTime = microtime(true);
        $result     = $this->link->query($this->bulid['sql']);
        $_endTime   = microtime(true);

        $this->sqlInfo['time'] = $_endTime - $_beginTime; // 获取执行时间
        $this->sqlInfo['sql']  = $this->bulid['sql'];

        // 执行成功
        if ($result) {

            // 存入调试信息中
            Trace::addSqlInfo($this->sqlInfo);
            // 存入文件中
            if ($this->config['save_log']) {
                $this->addSqlLog();
            }

            return $result;
        } else {
            // 存入文件
            if ($this->config['error_log']) {
                $this->addErrorSqlLog();
            }

            if (config('debug')) {
                throw new Exception('SQL ERROR : ' . $this->bulid['sql']);
            }

            if (config('trace')) {
                Trace::addErrorInfo('[SQL ERROR] ' . $this->bulid['sql']);
            }

            return false;

        }

    }
执行
@date   2017-03-19T16:20:36+0800
@author ChenMingjiang
@param  [type]                   $sql [description]
@return [type]                        [description]