处理 :xxx 参数转为 ? 问号参数
@param string $sql
@param array $params
@return string
175279
public function parseSqlNameParamsToQuestionMark($sql, &$params)
    {
        $params = [];
        $hash = Random::letter(16, 16);
        $items = [];
        $index = 0;
        // 先替换字符串
        $sql = preg_replace_callback('/\'([^\']+)\'/', function($matches) use($hash, &$items, &$index){
            $items[] = $matches[0];
            $returnValue = $hash . '-' . $index;
            ++$index;
            return $returnValue;
        }, $sql);

        // 匹配 :xxx 参数
        $i = 0;
        $sql = preg_replace_callback('/(\?|:\w+)/', function($matches) use(&$params, &$i){
            if('?' === $matches[1])
            {
                $params[] = $i;
            }
            else
            {
                $params[] = $matches[1];
            }
            ++$i;
            return '?';
        }, $sql);

        // 把开始的替换回来
        for($index -= 1; $index >= 0; --$index)
        {
            $sql = str_replace($hash .'-' . $index, $items[$index], $sql);
        }

        return $sql;
    }
1192366
public function getValue($sql, $params = null)
    {
        $this->log('getValue', $sql, $params);

        return $this->_socket->getValue($sql, $params);
    }
752911
public function createCommand($sql = null, $params = [])
    {
        $command = new Command([
            'db' => $this,
            'sql' => $sql,
        ]);

        return $command->bindValues($params);
    }
167015
public function order(string $sql, array $params = []) : self
    {
        $this->qiterator = null;
        $name = null;
        if (!count($params)) {
            $name = preg_replace('(\s+(ASC|DESC)\s*$)i', '', $sql);
            try {
                $name = $this->getColumn(trim($name))['name'];
            } catch (\Exception $e) {
                $name = null;
            }
        }
        $this->order = [ $sql, $params, $name ];
        return $this;
    }
1002683
public function whereNotExistsRaw(string $sql, string ...$params)
    {
        $this->wConditions = null;

        $this->exists = [
            'sql'    => $sql,
            'negate' => true,
            'params' => $params,
        ];

        return $this;
    }
577075
public function createSqlCommand($sql,$params=array())
	{
		$command=$this->_connection->createCommand($sql);
		$this->bindValues($command,$params);
		return $command;
	}
432604
protected function replaceParams($sql, array $params) {
		$i=0;
		return preg_replace_callback('/\?/', function() use(&$i, $params, $sql) {
			$rep = $params[$i++];
			if(!$rep instanceof Raw && !$rep instanceof static)
				return "'".addslashes($rep)."'";
			else
				return '?';
		}, $sql);
	}
217497
public function sqlExecute(string $sql, array $params = []): int
    {
        return $this->connection()->sqlExecute($sql, $params);
    }
1141130
public function queryColumn($sql = null,$params = array())
	{
		if(!isset($this->operationOption['params']))
		{
			$this->operationOption['params'] = array();
		}
		$this->prepareQuery($sql ? $sql : $this->buildSelectSQL(),$params);
		if(false === $this->lastStmt)
		{
			return false;
		}
		else
		{
			return $this->lastStmt->fetchAll(PDO::FETCH_COLUMN);
		}
	}
48339
public function query($sql, array $params = []) {
        $start_time = microtime(true);
        $this->sql  = $sql;
        $this->query->build()->reset();
        #准备sql
        $sth = $this->getLink(false)->prepare($sql);
        #设置保存数据
        $sth->setFetchMode(PDO::FETCH_ASSOC);
        #绑定参数
        $params = $this->setParamsSort($params);
        foreach ((array) $params as $key => $value) {
            $sth->bindParam($key, $params[$key], is_numeric($params[$key]) ? PDO::PARAM_INT : PDO::PARAM_STR);
        }
        try {
            #执行查询
            $sth->execute();
            $this->affectedRow = $sth->rowCount();
            $data              = $sth->fetchAll() ?: [];
            #记录日志
            if (DEBUG) {
                $end_time = microtime(true);

                self::$queryLog[] = array(
                    'sql'  => sql_processing($sql, $params),
                    'data' => to_json($data),
                    'time' => ($end_time - $start_time) . 'μs',
                );
            }
            return $data;
        } catch (Exception $e) {
            $error = $sth->errorInfo();
            throw new Exception($sql . " ;BindParams:" . var_export($params, true) . implode(';', $error));
        }
    }
1211662
public function execute($sql, array $params=null) {
        list($sql, $params, $type) = $this->fix_sql_params($sql, $params);

        $result = true;
        $this->query_start($sql, $params, SQL_QUERY_UPDATE);

        try {
            $sth = $this->pdb->prepare($sql);
            $sth->execute($params);
        } catch (PDOException $ex) {
            $this->lastError = $ex->getMessage();
            $result = false;
        }

        $this->query_end($result);
        return $result;
    }
591968
public function orWhereRaw(string $sql, string ...$params)
    {
        $this->wConditions()->orRaw($sql, ...$params);

        return $this;
    }
1007927
public function getOne($sql, $params = array(), $column_number = 0)
    {
        $stmt = $this->execute($sql, $params);
        return $stmt->fetchColumn($column_number);
    }
1048580
public function getResults($sql, $params = null)
    {
        $this->log('getResults', $sql, $params);

        return $this->_socket->getResults($sql, $params);
    }
153939
public function whereRaw(string $sql, string ...$params)
    {
        $this->wConditions()->raw($sql, ...$params);

        return $this;
    }
1177010
public function query($sql, array $params = array())
    {
        //$helper = $this->getHelper();
        $con = $this->establishConnection();
        $sth = $con->prepare($sql, array(Connection::ATTR_CURSOR => Connection::CURSOR_SCROLL));

        // bind params
        foreach($params as $key => $value){
            $type = Connection::PARAM_STR;
            if ( is_null($value) ) {
                $type = Connection::PARAM_NULL;
            } elseif ( is_int($value) ) {
                $type = Connection::PARAM_INT;
            } elseif ( is_bool($value) ) {
                $type = Connection::PARAM_BOOL;
            } elseif ( is_resource($value) ) {
                $type = Connection::PARAM_LOB;
            }
            if ( is_int($key) ) {
                $sth->bindValue($key + 1, $value, $type);
            } else {
                $sth->bindValue($key, $value, $type);
            }
        }

        $result = $sth->execute();
        return $sth;
    }
1277492
public function execute($sql, array $params=array())
	{
		if ($params) {
			$stmt = $this->prepare($sql);
			if (!$stmt) { return false; }

			$flag = $stmt->execute($params);
			if (!$flag) { return false; }
		} else {
			$stmt = $this->query($sql);
			if (!$stmt) { return false; }
		}

		return $stmt->rowCount();
	}