Performs a general query. It executes all the statements separated by a semicolon.

@param string $query Full SQL query
@throws PDOException
195563
public function statements(string $query)
    {
        try {
            $this->pdo->exec($query);
        } catch (\Throwable $exception) {
            throw static::wrapException($exception, $query);
        }
    }
138225
public function statement( $query, $params = array() )
	{
		// we alway prepare the query even if we dont have parameters
		$sth = $this->driver()->connection()->prepare( $query );
		
		// because we set pdo the throw exception on db errors
		// we catch them here to throw our own exception.
		try 
		{
			$sth->execute( $params );
		}
		catch ( \PDOException $e ) 
		{
			throw new Exception( "DB\\Handler - PDOException: {$e->getMessage()} \n Query: {$query}" );
		}
		
		// In development we alway log the query into an array.
		if ( \ClanCats::in_development() ) 
		{	
			$keys = array();
			
			foreach ( $params as $key => $value ) 
			{
				if ( is_string( $key ) ) 
				{
					$keys[] = '/:'.$key.'/';
				} else {
					$keys[] = '/[?]/';
				}
			}
			
			static::$_query_log[] = preg_replace( $keys, $params, $query, 1 );
		}
		
		return $sth;
	}
84138
public function executeRow0(string $query): ?array
  {
    $result = $this->query($query);
    $row    = $result->fetch_assoc();
    $n      = $result->num_rows;
    $result->free();

    if ($this->mysqli->more_results()) $this->mysqli->next_result();

    if (!($n==0 || $n==1))
    {
      throw new ResultException('0 or 1', $n, $query);
    }

    return $row;
  }
1343319
private function _mysql_query($query) {

        // call "mysqli_query"
        $result = mysqli_query($this->link, $query);

        // stop if there was an error
        if (!$result) throw new Exception($this->_mysql_error());

        // return the result if query was successful
        return $result;

    }
1093016
private function executeCreateUpdateQuery (&$query)
	{
		
		// Execute

		try
		{
			$query->execute ();
			return TRUE;
		}
		catch (\PDOException $e)
		{
			
			// Catch some errors
			
			switch ($e->getCode ())
			{
				
				// Duplicate Key
				
				case 23000:
				
					// Get attribute name and set error

					if (preg_match ('/Duplicate entry \'(.*?)\' for key \'(.*?)\'/', $e->getMessage (), $match))
					{
						$name	= $this->attributeExists ($match[2]) && isset (static::$attributes[$match[2]]['name'])? static::$attributes[$match[2]]['name'] : $match[2];
						new Message ('error',  'Please choose another ' . ucwords ($name) . ' `' . $match[1] . '` already exists!');
						return FALSE;
					}

					// Else unrecognised message so throw the error again

					else
					{
						throw $e;
					}
					
					break;
					
					
				// Throw error by default
					
				default:
					throw $e;
				
			}
			
		}
		
	}
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;
    }
694091
protected function exec($query)
    {
        try {
            Connect::getConn()->exec($query);
        } catch (Exception $e) {
            static::$response["status"] = "error";
            static::$response["response"] = $e->getMessage();
            static::$response["code"] = $e->getCode();

            return static::terminate(static::$response);
        }
        return null;
    }
904586
public function execute(Query $query)
    {
        // Get native query for SimpleExpression
        $nativeQuery = $this->getNativeQuery($query);

        $queryParts = array();
        parse_str($nativeQuery, $queryParts);

        // pass http query parts 
        return $this->getClient()->lookup($queryParts);
    }
1206695
public function execute( $query, $debug = 1 )
	{
		$result = false;
		if( $query )
		{
			if( $debug > 0 )
			{
				$bits = $this->getBits( $debug, 5 );
				if( $bits[0] )
				{
					$this->countQueries++;
					$start = $this->getMicroTime();
				}
				if( $bits[1] )
					echo $query;
				if( $bits[2] )
					remark( $query );
				if( $bits[3] )
					die();
			}
			if( preg_match( '/^INSERT/i', ltrim( $query ) ) )
			{
				if( $result = pg_query( $this->dbc, $query ) )
				{
					$this->insertId = (int) pg_last_oid( $result );
					$result	= $this->insertId;
				}
			}
			else if( preg_match( '/^(SELECT|SHOW)/i', ltrim( $query ) ) )
			{
				$result = new DB_Result();
				if( $q = pg_query( $this->dbc, $query ) )
				{
					while( $d = pg_fetch_array( $q ) )
					{
						$row = new DB_Row();
						foreach( $d as $key => $value )
							$row->$key = $value;
						$result->rows[] = $row;
					}
				}
			}
			else
			{
				$result = pg_query( $this->dbc, $query );
			}
			if( pg_last_error() )
				$this->handleError( 0/*pg_errno()*/, pg_last_error(), $query );
			if( $debug > 0 )
			{
				if( $bits[0] )
					$this->countTime += $this->getTimeDifference( $start );
				if( $bits[4] )
					die();
			}
			return $result;
		}
	}
463350
public function formExtendQuery($query)
    {
        if (!$this->user->isSuperUser()) {
            $query->where('is_superuser', false);
        }

        // Ensure soft-deleted records can still be managed
        $query->withTrashed();
    }
365236
public function bindValues($query) {
        if (!empty($this->bind_values) && !empty($this->bind_keys)) {
            if (!$query instanceof \PDOStatement) {
                $this->setError('q', 'No valid PDO Statement provided');
            }

            for ($ii = 0; $ii < count($this->bind_values); $ii++) {
                $param = $this->get_PDO_param($this->bind_values[$ii]);
                $value = $this->bind_values[$ii];
                $key = $this->bind_keys[$ii];

                $query->bindValue($key, $value, $param);
            }
        }
    }
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;
    }
24745
function executeQuery($query) {

        try {

            $table = FALSE;

            if (!is_null($query) && is_string($query)) {
                $connection = $this->getConnection();
                $resultQry = mysql_query($query, $connection);

                if ($resultQry) {

                    if (mysql_num_rows($resultQry) != 0) {

                        $rowTemplate = array();
                        $terminar = FALSE;
                        $cntCols = mysql_num_fields($resultQry);
                        $cnt = 0;

                        while (!$terminar) {

                            $nombreCampo = mysql_field_name($resultQry, $cnt);

                            if ($nombreCampo) {
                                $rowTemplate[$nombreCampo] = $nombreCampo;
                                $cnt = $cnt + 1;
                            }

                            $terminar = (( $cntCols - $cnt ) == 0);
                        }

                        $table = array();

                        while ($fila = mysql_fetch_assoc($resultQry)) {

                            $rowAux = $rowTemplate;

                            foreach ($rowAux as $k => $v) {
                                $rowAux[$k] = $fila[$k];
                            }

                            $table[] = $rowAux;
                        }

                        mysql_free_result($resultQry);
                    }

                    mysql_close($connection);
                } else {
                    throw new \Exception("SQL Error: " . mysql_error());
                }
            }

            return $table;
        } catch (\Exception $pEx) {
            throw new \Exception("Fallo al ejecutar la query: " . $query . "  " . $pEx->getMessage());
        }
    }
313127
public function execute()
	{
		$this->connect();

		// Take a local copy so that we don't modify the original query and cause issues later
		$sql = $this->replacePrefix((string) $this->sql);

		if ($this->limit > 0 || $this->offset > 0)
		{
			$sql = $this->limit($sql, $this->limit, $this->offset);
		}

		// Increment the query counter.
		$this->count++;

		// If debugging is enabled then let's log the query.
		if ($this->debug)
		{
			// Add the query to the object queue.
			$this->log(
				Log\LogLevel::DEBUG,
				'{sql}',
				array('sql' => $sql, 'category' => 'databasequery', 'trace' => debug_backtrace())
			);
		}

		// Reset the error values.
		$this->errorNum = 0;
		$this->errorMsg = '';

		$options = array();

		// SQLSrv_num_rows requires a static or keyset cursor.
		if (strncmp(strtoupper(ltrim($sql)), 'SELECT', \strlen('SELECT')) === 0)
		{
			$options = array('Scrollable' => SQLSRV_CURSOR_KEYSET);
		}

		$params = array();

		// Bind the variables:
		if ($this->sql instanceof PreparableInterface)
		{
			$bounded =& $this->sql->getBounded();

			if (\count($bounded))
			{
				foreach ($bounded as $key => $obj)
				{
					// And add the value as an additional param
					$params[] = $obj->value;
				}
			}
		}

		// Execute the query. Error suppression is used here to prevent warnings/notices that the connection has been lost.
		$this->cursor = @sqlsrv_query($this->connection, $sql, $params, $options);

		// If an error occurred handle it.
		if (!$this->cursor)
		{
			// Check if the server was disconnected.
			if (!$this->connected())
			{
				try
				{
					// Attempt to reconnect.
					$this->connection = null;
					$this->connect();
				}
				catch (ConnectionFailureException $e)
				{
					// If connect fails, ignore that exception and throw the normal exception.
					$errors         = sqlsrv_errors();
					$this->errorNum = $errors[0]['code'];
					$this->errorMsg = $errors[0]['message'];

					// Throw the normal query exception.
					$this->log(
						Log\LogLevel::ERROR,
						'Database query failed (error #{code}): {message}; Failed query: {sql}',
						array('code' => $this->errorNum, 'message' => $this->errorMsg, 'sql' => $sql)
					);

					throw new ExecutionFailureException($sql, $this->errorMsg, $this->errorNum);
				}

				// Since we were able to reconnect, run the query again.
				return $this->execute();
			}

			// The server was not disconnected.
			$errors         = sqlsrv_errors();
			$this->errorNum = $errors[0]['code'];
			$this->errorMsg = $errors[0]['message'];

			// Throw the normal query exception.
			$this->log(
				Log\LogLevel::ERROR,
				'Database query failed (error #{code}): {message}; Failed query: {sql}',
				array('code' => $this->errorNum, 'message' => $this->errorMsg, 'sql' => $sql)
			);

			throw new ExecutionFailureException($sql, $this->errorMsg, $this->errorNum);
		}

		return $this->cursor;
	}
834826
public function query($query) {
    if(method_exists($this->db, 'query')) {
      return $this->db->query($query);
    } else {
      throw new Exception(__METHOD__ . " not implemented");
    }
  }
589397
public function execute($query) {
		$query = $query->compile();
		return $this->driver->query($query->sql(), $query->params());
	}
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;
        }