Performs the actual query and returns the results

@param   string  $query      The query to perform
@param   string  $structure  The structure of the item(s) returned (if applicable)
@return  mixed
@since   2.0.0
544928
public function query($query, $structure = null)
	{
		// Check the type of query to decide what to return
		list($type) = explode(' ', $query, 2);
		$type       = strtolower($type);

		// Default structure if needed
		if ($type == 'select' && is_null($structure))
		{
			$structure = 'rows';
		}

		$this->connection->prepare($query)->bind($this->syntax->getBindings());

		$result = (isset($structure))
		        ? $this->connection->{constant('self::' . strtoupper($structure))}()
		        : $this->connection->query();

		return $result;
	}
937803
protected function structure_charset($structure)
    {
        while (is_array($structure)) {
            if (is_array($structure[2]) && $structure[2][0] == 'charset') {
                return $structure[2][1];
            }
            $structure = $structure[0];
        }
    }
79261
public function getResults($query)
    {
        $parameters = [];

        if (is_object($query) && $query instanceof SearchQuery) {
            $query = $query->toArray();
        }

        if (is_array($query)) {
            $collection = new Collection($query);

            $query = $collection->pull('query', '');

            $parameters = $collection->toArray();
        }

        return $this->index->search($query, $parameters);
    }
919274
public function query($query, array $binds = array())
    {
        //Argument 1 must be a string or null
        Argument::i()->test(1, 'string', self::QUERY);
        
        $request = new \stdClass();
        
        $request->query = $query;
        $request->binds = $binds;
        
        //event trigger
        $this->trigger('sql-query-before', $request);
        
        $connection = $this->getConnection();
        $query      = (string) $request->query;
        $stmt       = $connection->prepare($query);
        
        //bind some more values
        foreach ($request->binds as $key => $value) {
            $stmt->bindValue($key, $value);
        }
        
        //PDO Execute
        if (!$stmt->execute()) {
            $error = $stmt->errorInfo();
            
            //unpack binds for the report
            foreach ($binds as $key => $value) {
                $query = str_replace($key, "'$value'", $query);
            }
            
            //throw Exception
            Exception::i()
                ->setMessage(Exception::QUERY_ERROR)
                ->addVariable($query)
                ->addVariable($error[2])
                ->trigger();
        }
        
        $results = $stmt->fetchAll(\PDO::FETCH_ASSOC);
        
        if($this->queryCache) {
            //log query
            $this->queries[] = array(
                'query'     => $query,
                'binds'     => $binds,
                'results'   => $results);
        }

        //clear binds
        $this->binds = array();
        
        //event trigger
        $this->trigger('sql-query-after', $query, $binds, $results);
        
        return $results;
    }
940666
protected function execute($query)
    {
        $query->execute($this->bindings);
        
        $this->bindings = [];
        $this->wheres   = [];

        return $query;
    }
5277
protected function executeQuery($query)
        {
            $res = @odbc_exec($this->_lnk, $query);
            if(!$res) {
                $error = odbc_errormsg($this->_lnk);
                $this->log('Query failed: '.$error);
                throw new Exception('Executing query failed ' . $error, self::QUERY_FAILED);
            }
            return $res;
        }
1212462
public function query($query=null)
    {
        if (!static::isSql($query)) {
            $this->checkQuery($query);
            $query = null;
        }
        
        return $this->getDb()->setQuery($this->getQuery())->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;
    }
871678
protected function executeQuery($query)
    {
        $content = $this->getAdapter()->get($query)->getBody();

        if (null === $content) {
            throw new NoResult(sprintf('Could not execute query: %s', $query));
        }

        $json = json_decode($content, true);

        if (!empty($json['error']) && strtolower($json['error']) == 'invalid api key') {
            throw new InvalidCredentials('Invalid API Key');
        } elseif (!empty($json['error'])) {
            throw new NoResult(sprintf('Error returned from api: %s', $json['error']));
        }

        if (empty($json['results'])) {
            throw new NoResult(sprintf('Could not find results for given query: %s', $query));
        }

        $locations = $json['results'];

        $results = array();

        $ctr = 0;

        foreach ($locations as $location) {
            $ctr++;

            if ($ctr <= $this->getLimit()) {

                $coordinates = $location['location'];
                $address = $location['address_components'];

                //Geocodio does not always return a street, number, or suffix
                if (!isset($address['street']) && isset($json['input']['address_components']['street'])) {
                    //Sometimes Geocodio returns parsed information in the input
                    $addressInput = $json['input']['address_components'];
                    $address['street'] = $addressInput['street'];
                    $address['number'] = $addressInput['number'];
                    $address['suffix'] = $addressInput['suffix'];
                } elseif (!isset($address['street'])) {
                    $address['street'] = '';
                    $address['number'] = ''; // No Street = No Number
                    $address['suffix'] = '';
                }

                if (!empty($address['suffix'])) {
                    $address['street'] .= ' ' . $address['suffix'];
                }

                $results[] = array_merge($this->getDefaults(), array(

                        'latitude'      => $coordinates['lat'] ?: null,
                        'longitude'     => $coordinates['lng'] ?: null,
                        'streetNumber'  => $address['number'] ?: null,
                        'streetName'    => $address['street'] ?: null,
                        'city'          => $address['city'] ?: null,
                        'zipcode'       => $address['zip'] ?: null,
                        'county'        => $address['county'] ?: null,
                        'region'        => $address['state'] ?: null,
                        'country'       => 'US'
                    ));
            }
        }

        return $results;
    }
609955
public function scopeStillActive($query)
    {
        $query->where(function ($query) {
            return $query->where('start_at', '<=', Carbon::now())->orWhereNull('start_at');
        })
        ->where(function ($query) {
            return $query->where('end_at', '>=', Carbon::now())->orWhereNull('end_at');
        })
        ->where(function ($query) {
            return $query->where('parent_id', 0)->orWhereNull('parent_id');
        });

        return $query;
    }
385206
public function buildQuery($query)
    {
        $q = $this->request->getQuery();

        foreach ($query as $key => $value)
        {
            $q[$key] = $value;
        }
    }
79274
protected function selectmultiple_button(structure $structure) {
        $buttonoptions = array(
            'type'  => 'button',
            'name'  => 'selectmultiple',
            'id'    => 'selectmultiplecommand',
            'value' => get_string('selectmultipleitems', 'quiz'),
            'class' => 'btn btn-secondary mb-1'
        );
        if (!$structure->can_be_edited()) {
            $buttonoptions['disabled'] = 'disabled';
        }

        return html_writer::tag('button', get_string('selectmultipleitems', 'quiz'), $buttonoptions);
    }
213072
public function getAction(Request $request)
    {
        $structureProvider = $this->get('sulu.content.structure_manager');
        $type = $request->get('type', 'default');

        $templates = [];
        foreach ($structureProvider->getStructures('article') as $structure) {
            if ($this->getType($structure->getStructure()) !== $type) {
                continue;
            }

            $templates[] = [
                'internal' => $structure->getInternal(),
                'template' => $structure->getKey(),
                'title' => $structure->getLocalizedTitle($this->getUser()->getLocale()),
            ];
        }

        return new JsonResponse(
            [
                '_embedded' => $templates,
                'total' => count($templates),
            ]
        );
    }
886803
public function query(
        Query $query,
        array $parameters = []
    ): Result {
        $this->load();

        return parent::query($query);
    }
225431
public function retrieve($query)
	{
		// Eager load configured relationships.
		$query = $this->setEagerLoaded($query);

		// Execute the query.
		$retrieved = $query->get();

		// Eager load configured relationships.
		return $this->setLazyLoaded($retrieved);
	}
697433
public function execute($query)
    {
        $this->_queries[] = $query;

        $sql = is_string($query) ? $query : $query->getString();

        $resultSQL = $this->getAdapter()->execute($sql);
        $result = new Result($resultSQL, $this->getAdapter());
        $result->setQuery($query);

        return $result;
    }
60268
private function _query($query)
    {
        $db = $this->_getConnection();
        if (is_resource($db)) {
            $res = @sqlite_query($db, $query);
            if ($res === false) {
                return false;
            } else {
                return $res;
            }
        }
        return false;
    }