Run a select statement against the database.

@param  string  $query
@param  array   $bindings
@return array
355332
public function select($query, $bindings = array()) {
        return $this->run($query, $bindings, function(self $me, $query, array $bindings) {
                    if ($me->pretending())
                        return array();
                    // For select statements, we'll simply execute the query and return an array
                    // of the database result set. Each element in the array will be a single
                    // node from the database, and will either be an array or objects.
                     $statement = $me->getBatchQuery($query, $bindings);
                    return $statement->getResultSet();
                    
                    // $statement = $me->getCypherQuery($query, $bindings);
                    // return $statement->getResultSet();

                });
    }
1335935
final public function loadFromQuery($query, array $binds = [])
    {
        $this->source()->loadItemFromQuery($query, $binds, $this);
        return $this;
    }
153721
public function prepare(string $statement, array $bindings = []): RawQueryBuilder
    {
        $this->statement = $statement;
        $this->bindings = $bindings;

        return $this;
    }
736154
protected function affectingStatement($query, $bindings = array())
    {
        $statement  = $this->getActivePdo()->prepare($query);

        $statement->execute($bindings);

        return $statement->rowCount();
    }
712237
protected function run( $query, $bindings, Closure $callback ) {
		$start = microtime( true );

		// Prevent showing the errors.
		$suppress_errors = $this->wpdb->suppress_errors;
		$this->wpdb->suppress_errors( true );

		// Here we will run this query. If an exception occurs we'll determine if it was
		// caused by a connection that has been lost. If that is the cause, we'll try
		// to re-establish connection and re-run the query with a fresh connection.
		try {
			$result = $this->runQueryCallback( $query, $bindings, $callback );
		} catch ( \Exception $e ) {
			$result = $this->handleQueryException( $e, $query, $bindings );
		}

		// Once we have run the query we will calculate the time that it took to run and
		// then log the query, bindings, and execution time so we will report them on
		// the event that the developer needs them. We'll log time in milliseconds.
		$this->logQuery( $query, $bindings, $this->getElapsedTime( $start ) );

		$this->wpdb->suppress_errors( $suppress_errors );

		return $result;
	}
1153316
public function setBindings($bindings): Query
    {
	    if (is_array($bindings)) {
		    $this->bindings = new Bindings();
		    $this->bindings->setFromArray($bindings);

	    } else if ($bindings instanceof Bindings) {
		    $this->bindings = $bindings;

	    } else {
		    throw new \InvalidArgumentException('Invalid second argument provided, expected null, array or instance of Bindings');
	    }

        return $this;
    }
707058
protected function execute(string $query, array $bindings = [])
    {
        $query = N1qlQuery::fromString($query);
        $query->consistency($this->consistency);
        $query->crossBucket($this->crossBucket);
        $query->positionalParams($bindings);
        $result = $this->executeQuery($query);
        $this->metrics = $result->metrics ?? [];

        return $result;
    }
1309318
public function affectingStatement( $query, $bindings = [] )
	{
		$new_query = $this->bind_params( $query, $bindings, true );

		$result = $this->db->query( $new_query );

		if ( $result === false || $this->db->last_error ) {
			throw new QueryException( $new_query, $bindings, new \Exception( $this->db->last_error ) );
		}

		return intval( $result );
	}
634798
protected function compileFromPart(Query $query, array &$bindings): string
    {
        if ($query->table === null) {
            throw new InvalidQueryException('The FROM table is not set');
        }

        return 'FROM '.$this->compileIdentifierWithAlias($query->table, $query->tableAlias, $bindings);
    }
453207
public function affectingStatement($query, $bindings = [])
    {
        $start = $this->getLogTime();

        try {

            $result = $this->wpdb->query($this->bindParams($query, $bindings, true));

            if ($result === false || $this->wpdb->last_error) {
                throw new QueryException($query, $bindings, new \Exception($this->wpdb->last_error));
            }

            return intval($result);

        } catch (QueryException $e) {
            throw $e;
        } finally {
            $this->logQuery($query, $bindings, $this->getElapsedTime($start));
        }
    }
922745
public function statement($query, $bindings = array())
    {
        $self = $this;

        return $this->run($query, $bindings, function($query, $bindings) use ($self) {
            if ($self->pretending()) return true;

            // pass query to CodeIgniter database layer
            $bindings = $self->prepareBindings($bindings);

            return (bool) $self->ci->db->query($query, $bindings);
        });
    }
920730
public function affectingStatement($query, $bindings = array())
    {
        return $this->run($query, $bindings, function ($me, $query, $bindings)
        {
            if ($me->pretending()) return 0;

            $bindings = $me->prepareBindings($bindings);

            //
            $statement = $me->createPdoStatement($query);

            $statement->execute($bindings);

            return $statement->rowCount();
        });
    }
650221
public function select( $query, $bindings = [], $useReadPdo = true )
	{
		return $this->run( $query, $bindings, function ( $me, $query, $bindings ) use ( $useReadPdo )
		{
			if ( $me->pretending() )
			{
				return [];
			}

			// For select statements, we'll simply execute the query and return an array
			// of the database result set. Each element in the array will be a single
			// row from the database table, and will either be an array or objects.
			$statement = $this->getPdoForSelect( $useReadPdo )->prepare( $query );

			$statement->execute( $me->prepareBindings( $bindings ) );

			$fetchMode = $me->getFetchMode();
			$fetchArgument = $me->getFetchArgument();

			if ( $fetchMode === PDO::FETCH_CLASS && !isset( $fetchArgument ) )
			{
				$fetchArgument = 'StdClass';
			}

			return isset( $fetchArgument ) ? $statement->fetchAll( $fetchMode, $fetchArgument, $me->getFetchConstructorArgument() ) : $statement->fetchAll( $fetchMode );
		} );
	}
1105172
private function interpolate($query, $bindings)
	{
		$offset = 0;
		$index  = 0;

		foreach (Str::findLiteral('?', $query) as $placeholder)
		{
			$sub     = (is_null($bindings[$index])) ? 'NULL' : $this->quote($bindings[$index]);
			$query   = substr_replace($query, $sub, $placeholder + $offset, 1);
			$offset += (strlen($sub) - 1);
			$index++;
		}

		return $query;
	}
759297
public function selectOne( $query, $bindings = [] )
	{
		$records = $this->select( $query, $bindings );

		return count( $records ) > 0 ? reset( $records ) : null;
	}
53712
public function logQuery( string $query, array $bindings, $time = null )
	{
		$this->queries ++;
		if( $time )
		{
			$this->timing += $time;
		}
		if( isset( $this->events ) )
		{
			$this->events->dispatch( new Events\QueryExecutedEvent( $this, $query, $bindings, $time ?? 0 ) );
		}
		if( $this->loggingQueries )
		{
			$this->queryLog[] = compact( 'query', 'bindings', 'time' );
		}
	}
215356
public function statement($query, $bindings = [])
    {
        return $this->run($query, $bindings, function ($query, $bindings) {
            if ($this->pretending()) {
                return true;
            }

            $statement = $this->getPdo()->prepare($query);

            $this->bindValues($statement, $this->prepareBindings($bindings));

            return $statement->execute();
        });
    }