************************************\
Returns many results from the database
@param  string $query  => the database query
@param  array  $params => (the query parameters)
@return mixed          => the results
189518
public function results(string $query, array $params = [])
    {
        // Prepares the query, then stores it
        $PDOStatement = $this->pdo->prepare($query);

        // Executes the prepared query
        $PDOStatement->execute($params);

        // Fetchs all results, then returns them
        return $PDOStatement->fetchAll();
    }
911331
public static function setParams($query, array $params = []) {
        Str::assert($query, 'query');

        return array_reduce($params, function($query, $param) {
            $param = self::getStringRepresentation($param);

            return strpos($query, '?') ? substr_replace($query, $param, strpos($query, '?'), strlen('?')) : $query;
        }, $query);
    }
413071
final public function queryArray(string $query)
    {
        $result = $this->queryResult($query);
        if (false === $result) {
            return false;
        }

        $return = [];
        while (false !== $row = $result->fetchRow()) {
            $return[] = $row;
        }
        return $return;
    }
820226
public function query($query = '', $params = null, $fetchmode = PDO::FETCH_ASSOC)
    {
        $query = trim($query);
        if (empty($query)) {
            $query = $this->build();
            if (!$params) {
                $params = $this->getBindValues();
            }
        }

        $this->resetAll();
        $this->lastSql = $query;

        $this->execute($query, $params);

        $rawStatement = explode(" ", $query);

        $statement = strtolower(trim($rawStatement[0]));
        if ($statement === 'select' || $statement === 'show') {
            return $this->sQuery->fetchAll($fetchmode);
        } elseif ($statement === 'update' || $statement === 'delete') {
            return $this->sQuery->rowCount();
        } elseif ($statement === 'insert') {
            if ($this->sQuery->rowCount() > 0) {
                return $this->lastInsertId();
            }
        } else {
            return null;
        }

        return null;
    }
1237230
public final function get(string $query, array $queryParams = null, string $fetchClass = null)
    {
        return $this->query($query, $queryParams, 1, $fetchClass)->getData(0);
    }
881809
public function query($query, array $params = [])
    {
        // Execute query
        $stmt = $this->connection->prepare($query);
        $stmt->execute($params);
        // Return result resource variable
        return $stmt;
    }
244973
public function query(array $params = []) {
        $this->params = array_merge($this->params, $params);
        return $this->db->query($this->sql, $this->params);
    }
333611
protected function _insert($query, $params)
    {
        $db = $this->db;
        $sth = $db->prepare($query);

        foreach ($params as $key => $val) {
            if (is_int($val)) {
                $sth->bindValue("$key", $val, $db::PARAM_INT);
            } else {
                $sth->bindValue("$key", $val);
            }
        }

        $response = $sth->execute();

        if ($response) {

            $class = $this->_rowClass;
            $row = new $class($this, $db->lastInsertId());

            return $row;
        }
        return false;
    }
884064
protected function prepareParams($query, $sqlParams)
    {
        if (empty($sqlParams)) {
            $sqlParams = [];
        }
        uksort(
            $sqlParams,
            function ($k1, $k2) {
                return strlen($k1) < strlen($k2);
            }
        );
        $resultQuery = $query;
        $paramNum = 0;
        foreach ($sqlParams as $paName => $paValue) {
            if (gettype($paValue)==="array") {
                $paramList = [];
                foreach ($paValue as $i=>$value) {
                    // $paramList[] = $paName . "_param$i";
                    $paramList[] = ":pdoParam$paramNum";
                    $paramNum++;
                }
                $resultQuery = str_replace($paName, implode(",", $paramList), $resultQuery);
            }
        }
        return $resultQuery;
    }
976018
public function queryAndReturnResult($query, $params = [])
    {
        $schema = $this->schema();
        $context = $this->getContext();

        $last = function ($schema, $query, $context, $params) {
            return GraphQL::executeQuery($schema, $query, null, $context, $params);
        };

        return $this->callMiddleware($schema, $query, $context, $params, $last);
    }
1015319
public function findByParams($params = [])
    {
        $query = $this->paramsToQuery($params);

        return $this->findByQuery($query, $params);
    }
609752
public function executeQuery($query, array $params = []) {
        $this->connect();

        $cacheKey = null;
        $cacheLength = null;

        // Determine cache key and lengths
        if ($query instanceof Query) {
            $cacheKey = $query->getCacheKey();
            $cacheLength = $query->getCacheLength();

        } else if (!is_string($query)) {
            throw new InvalidQueryException('Query must be a raw SQL string or a Titon\Db\Query instance');
        }

        // Execute and return result
        return $this->_result = $this->cacheQuery($cacheKey, function(AbstractPdoDriver $driver) use ($query, $params) {
            $isQuery = ($query instanceof Query);

            // Prepare statement and bind parameters
            if ($isQuery) {
                $statement = $driver->buildStatement($query);
                $binds = $driver->resolveParams($query);

            } else {
                $statement = $driver->getConnection()->prepare($query);
                $binds = [];

                foreach ($params as $value) {
                    $binds[] = [$value, $driver->resolveType($value)];
                }
            }

            foreach ($binds as $i => $value) {
                $statement->bindValue($i + 1, $value[0], $value[1]);
            }

            $statement->params = $binds;

            // Gather and log result
            if ($isQuery) {
                $result = new PdoResultSet($statement, $query);
            } else {
                $result = new PdoResultSet($statement);
            }

            $driver->logQuery($result);

            return $result;
        }, $cacheLength);
    }
1173039
public function query($query, array $params = [])
    {
        $this->lastStatement = $this->getPDO()->prepare($query);
        $this->lastStatement->execute($this->prepareParams($params));
        return $this->lastStatement;
    }
451123
protected function _fetchRow($query, $params)
    {
        $db = $this->db;

        $sth = $db->prepare($query);
        foreach ($params as $key => $val) {
            if (is_int($val)) {
                $sth->bindValue("$key", $val, $db::PARAM_INT);
            } else {
                $sth->bindValue("$key", $val);
            }
        }
        $sth->execute();

        return $sth->fetch($db::FETCH_ASSOC);
    }
1184442
public function execute(string $query, array $params = []) : object
    {
        list($query, $params) = $this->expandParamArray($query, $params);

        if (!$this->pdo) {
            $this->createException("Did you forget to connect to the database?", $query, $params);
        }

        $this->stmt = $this->pdo->prepare($query);
        if (!$this->stmt) {
            $this->pdoException($query, $params);
        }

        if ($this->options["verbose"]) {
            echo $query . "\n";
            print_r($params);
        }

        $res = $this->stmt->execute($params);
        if (!$res) {
            $this->statementException($query, $params);
        }

        return $this;
    }
152773
public function query($query,$sqlParams=null)
    {
        $this->query =  (string)$query;
        if ($sqlParams!=null) {
            $this->sqlParams = $sqlParams;
        }
        return $this;
    }
1373706
public function searchStreams($query, $params = [])
  {
      $defaults = [
      'query'  => urlencode($query),
      'limit'  => 25,
      'offset' => 0,
      'hls'    => null,
    ];

      return $this->wrapper->request('GET', 'search/streams', ['query' => $this->resolveOptions($params, $defaults)]);
  }