查询多条记录
@param string $sql
@param array $params
@return array
321066
public function query($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_ASSOC);
		}
	}
869364
public function fetchColumn($sql, array $params=null, $column=0)
	{
        $sql .= " LIMIT 1";

		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->fetchColumn($column);
	}
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();
	}
368018
public function getRow($sql, $params = array())
    {
        $stmt = $this->execute($sql, $params);
        return $stmt->fetch($this->fetchMode);
    }
555583
protected function fetch( $sql, $params = null ) {
		$stmt = $this->dbh->prepare( $sql );
		$this->bind( $stmt, $params );
		$stmt->execute();
		return $stmt->fetch();
	}
343621
public static function getSqlWithParams(string $sql, array $params = []): string
    {
        if (! empty($params)) {
            $indexed = ($params === array_values($params));
            foreach ($params as $k => $v) {
                if (is_string($v)) {
                    $v = "'${v}'";
                }
                if (is_array($v)) {
                    $v = "'" . implode("','", $v) . "'";
                }
                if ($indexed) {
                    $sql = preg_replace('/\?/', $v, $sql, 1);
                } else {
                    $sql = str_replace(":${k}", $v, $sql);
                }
            }
        }

        return str_replace(PHP_EOL, '', $sql);
    }
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;
    }
252981
public function createCommand($sql = null, $params = [])
    {
        /** @var Command $command */
        $command = new $this->commandClass([
            'db' => $this,
            'sql' => $sql,
        ]);

        return $command->bindValues($params);
    }
537515
function execQueryString($sql, $params = null)
    {
        if (!is_array($params) && !is_null($params)) {
            $params = array($params);
        }

        $stmt = $this->prepare($sql);
        $stmt->execute($params);
        return $stmt;
    }
1273079
public function execute($sql, $params = null)
    {
        $stmt = $this->_pdo->prepare($sql);

        if (is_array($params)) {
            foreach ($params as $token => $value) {
                $stmt->bindValue($token, $value);
            }
        }

        try {
            $stmt->execute();
        } catch (PDOException $exception) {
            $this->_database->error('execute', $exception);
        }

        return $stmt;
    }
1135163
public function insert($sql, $params = array()) {
		$this->query($sql, $params);

		return $this->pdo->lastInsertId();
	}
744225
private function prepare($sql, array $params)
    {
        $statement = $this->connection->prepare($sql);
        foreach ($params as $key => $value) {
            $statement->bindValue($key, $value);
        }

        return $statement;
    }
686658
public function sqlFetchColumn(string $sql, array $params = [], string $column = '0')
    {
        return $this->connection()->sqlFetchColumn($sql, $params, $column);
    }
631472
public function getValues($sql, $params = null)
    {
        $this->log('getValues', $sql, $params);

        return $this->_socket->getColumn($sql, $params);
    }
70505
public function getArray($sql = null, $parameters = array()) {
		$this->execute($sql);
		$result = array();
		while (!!$objs = mysqli_fetch_assoc($this->result) ) {
			$result[] = $objs;
		}
		return $result;
	}
810069
public function query($sql=null, array $params=[]) {
		if($sql === null) {
			$sql = $this->buildSQL();
			$params = $this->getParameters();
		}

		$this->replaceArrayParams($sql, $params);

		return $this->query = $this->db->query($sql, $params);
	}
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));
        }
    }