src/NotORM/Result.php
public function query($query, $parameters){
        $debugTrace = array();

        self::$queryTimes++;

        /**
         * 修正当参数过多时的SQLSTATE[HY093] @dogstar 2014-11-18
         */
        $parameters = array_map(array($this, 'formatValue'), $parameters);
        foreach($parameters as $key => $val){
            if(substr($key, 0, 1) == ':' && stripos($query, $key) === false){
                unset($parameters[$key]);
            }
        }

        if($this->notORM->debug){
            $debugTrace['startTime'] = microtime(true);

            if(!is_callable($this->notORM->debug)){
                $debug = "$query;";
                if($parameters){
                    $debug .= " -- " . implode(", ", array_map(array($this, 'quote'), $parameters));
                }
                $pattern = '(^' . preg_quote(dirname(__FILE__)) . '(\\.php$|[/\\\\]))'; // can be static
                foreach(debug_backtrace() as $backtrace){
                    if(isset($backtrace["file"]) && !preg_match($pattern, $backtrace["file"])){ // stop on first file outside NotORM source codes
                        break;
                    }
                }
                /** @var array $backtrace */
                //error_log("{$backtrace['file']}:{$backtrace['line']}:$debug\n", 0);
                //if ($this->notORM->debug) echo "$debug<br />\n";    //@dogstar 2014-10-31

                $debugTrace['sql'] = $debug;
            }elseif(call_user_func($this->notORM->debug, $query, $parameters) === false){
                return false;
            }
        }

        $return = $this->notORM->connection->prepare($query);

        //对于替换参数进行处理   @喵了个咪 2015-12-25
        $sum = 1;
        foreach($parameters as $key => $val){
            if(strstr($key, ':')){
                if(is_int($val)){
                    $return->bindValue($key, $val, PDO::PARAM_INT);
                }elseif(is_bool($val)){
                    $return->bindValue($key, $val, PDO::PARAM_BOOL);
                }elseif(is_null($val)){
                    $return->bindValue($key, $val, PDO::PARAM_NULL);
                }else{
                    $return->bindValue($key, $val);
                }
            }else{
                if(is_int($val)){
                    $return->bindValue($sum, $val, PDO::PARAM_INT);
                }elseif(is_bool($val)){
                    $return->bindValue($sum, $val, PDO::PARAM_BOOL);
                }elseif(is_null($val)){
                    $return->bindValue($sum, $val, PDO::PARAM_NULL);
                }else{
                    $return->bindValue($sum, $val);
                }
                $sum++;
            }
        }

        $errorMessage = null;
        if(!$return || !$return->execute()){
            // fixed non-object bug @dogstar 20180326
            if ($return) {
                $errorInfo = $return->errorInfo();
                $errorMessage = isset($errorInfo[2]) ? $errorInfo[2] : $errorMessage;
            } else {
                $errorMessage = 'the database server cannot successfully prepare the statement';
            }

            $return = false;
        }

        if($this->notORM->debug){
            $debugTrace['endTime'] = microtime(true);

            $sqlInfo = sprintf("[%s - %sms]%s", 
                self::$queryTimes, 
                round(($debugTrace['endTime'] - $debugTrace['startTime']) * 1000, 2), 
                $debugTrace['sql']
            );

            if ($this->notORM->debugTimer && is_callable($this->notORM->debugTimer)) {
                call_user_func_array($this->notORM->debugTimer, array($sqlInfo));
            }
        }

        //显式抛出异常，以让开发同学尽早发现SQL语法问题 @dogstar 20150426
        if($return === false && $errorMessage !== null){
            throw new PDOException($errorMessage);
        }

        return $return;
    }
public function query($query, $parameters){
        $debugTrace = array();

        self::$queryTimes++;

        /**
         * 修正当参数过多时的SQLSTATE[HY093] @dogstar 2014-11-18
         */
        $parameters = array_map(array($this, 'formatValue'), $parameters);
        foreach($parameters as $key => $val){
            if(substr($key, 0, 1) == ':' && stripos($query, $key) === false){
                unset($parameters[$key]);
            }
        }

        if($this->notORM->debug){
            $debugTrace['startTime'] = microtime(true);

            if(!is_callable($this->notORM->debug)){
                $debug = "$query;";
                if($parameters){
                    $debug .= " -- " . implode(", ", array_map(array($this, 'quote'), $parameters));
                }
                $pattern = '(^' . preg_quote(dirname(__FILE__)) . '(\\.php$|[/\\\\]))'; // can be static
                foreach(debug_backtrace() as $backtrace){
                    if(isset($backtrace["file"]) && !preg_match($pattern, $backtrace["file"])){ // stop on first file outside NotORM source codes
                        break;
                    }
                }
                /** @var array $backtrace */
                //error_log("{$backtrace['file']}:{$backtrace['line']}:$debug\n", 0);
                //if ($this->notORM->debug) echo "$debug<br />\n";    //@dogstar 2014-10-31

                $debugTrace['sql'] = $debug;
            }elseif(call_user_func($this->notORM->debug, $query, $parameters) === false){
                return false;
            }
        }

        $return = $this->notORM->connection->prepare($query);

        //对于替换参数进行处理   @喵了个咪 2015-12-25
        $sum = 1;
        foreach($parameters as $key => $val){
            if(strstr($key, ':')){
                if(is_int($val)){
                    $return->bindValue($key, $val, PDO::PARAM_INT);
                }elseif(is_bool($val)){
                    $return->bindValue($key, $val, PDO::PARAM_BOOL);
                }elseif(is_null($val)){
                    $return->bindValue($key, $val, PDO::PARAM_NULL);
                }else{
                    $return->bindValue($key, $val);
                }
            }else{
                if(is_int($val)){
                    $return->bindValue($sum, $val, PDO::PARAM_INT);
                }elseif(is_bool($val)){
                    $return->bindValue($sum, $val, PDO::PARAM_BOOL);
                }elseif(is_null($val)){
                    $return->bindValue($sum, $val, PDO::PARAM_NULL);
                }else{
                    $return->bindValue($sum, $val);
                }
                $sum++;
            }
        }

        $errorMessage = null;
        if(!$return || !$return->execute()){
            // fixed non-object bug @dogstar 20180326
            if ($return) {
                $errorInfo = $return->errorInfo();
                $errorMessage = isset($errorInfo[2]) ? $errorInfo[2] : $errorMessage;
            } else {
                $errorMessage = 'the database server cannot successfully prepare the statement';
            }

            $return = false;
        }

        if($this->notORM->debug){
            $debugTrace['endTime'] = microtime(true);

            $sqlInfo = sprintf("[%s - %sms]%s", 
                self::$queryTimes, 
                round(($debugTrace['endTime'] - $debugTrace['startTime']) * 1000, 2), 
                $debugTrace['sql']
            );

            if ($this->notORM->debugTimer && is_callable($this->notORM->debugTimer)) {
                call_user_func_array($this->notORM->debugTimer, array($sqlInfo));
            }
        }

        //显式抛出异常，以让开发同学尽早发现SQL语法问题 @dogstar 20150426
        if($return === false && $errorMessage !== null){
            throw new PDOException($errorMessage);
        }

        return $return;
    }
放开限制 protected -> public @scott 反馈

@param $query        string
@param $parameters   array

@return bool|PDOStatement