Executes an SQL query. Returns:
- sql result in case of SELECT
- last insert ID in case of INSERT
- number of affected rows in case of UPDATE/DELETE

@param mixed $query
@return mixed
967137
public function execute($query = '')
    {
        if (\is_string($query) && $query !== '') {
            $this->currentQuery = $query;
        } elseif ($query instanceof Query) {
            $this->currentQuery = $query->___build();
        } elseif ($this->preparedQuery instanceof Query) {
            $this->currentQuery = $this->preparedQuery->___build();
        }

        if ($this->currentQuery == '') {
            $this->setError(AbstractMySQL::E_NO_SQL, __CLASS__);
            return null;
        }

        $startTime = $this->getMicrotime();
        if (\preg_match('/^CALL/mi', $this->currentQuery)) {
            $this->currentLink->multi_query($this->currentQuery);
            $result = $this->currentLink->store_result();
        } else {
            $result = $this->currentLink->query($this->currentQuery);
        }
        $queryTime = \round($this->getMicrotime() - $startTime, 4);
        $this->sqlQueries[] = ['query' => $this->currentQuery, 'queryTime' => $queryTime];

        if ($this->logHandler !== null) {
            $this->logHandler->logInfo($this->currentQuery, __CLASS__);
        }
        if (!$result && !\preg_match('/^CALL/mi', $this->currentQuery)) {
            $this->setError(AbstractMySQL::E_ENGINE_ERROR, __CLASS__);
        }

        if ($result instanceof \mysqli_result) {
            $ret = [];
            $this->rowCount = $result->num_rows;
            for ($i = 0; $i < $this->rowCount; $i++) {
                $ret[$i] = $result->fetch_assoc();
            }
            $result->close();
            if ($this->currentLink->more_results()) {
                while ($this->currentLink->next_result()) {
                    $result = $this->currentLink->store_result();
                    if ($result instanceof \mysqli_result) {
                        $result->close();
                    }
                }
            }
        } else {
            $this->rowCount = $this->currentLink->affected_rows;
            $ret = \preg_match('/^insert/mi', $this->currentQuery)
                ? $this->currentLink->insert_id
                : $this->rowCount;
        }
        if ($this->showQuery === true) {
            $fetchTime = \round($this->getMicrotime() - $startTime, 4);
            $queryText = \sprintf(
                '<b>Query %s:</b> %s; <b>[Q: %ss, F: %ss]</b><hr />',
                \count($this->sqlQueries),
                $this->currentQuery,
                $queryTime,
                $fetchTime
            );
            echo filter_var($queryText, FILTER_DEFAULT);
        }
        $this->currentQuery = '';

        return $ret;
    }
979897
protected function doQuery(Query $query)
    {
        $result = static::db()->query($query);

        $this->where = null;

        return $result;
    }
667242
public function executeLastInsertId($query, $parameters = [])
    {
        $statement = $this->link->prepare($query);
        $statement->execute($parameters);
        return $this->link->lastInsertId();
    }
1172785
public static function query($query)
    {
        //
        static::applySchema();

        //
        $table = self::getTable();
        $whereArray = [];

        //
        if (isset($query['where'])) {
            $whereArray[] = '('.$query['where'].')';
            unset($query['where']);
        }

        //
        foreach ($query as $field => $value) {
            if (in_array($field, ['order', 'limit'])) {
                continue;
            }
            $whereArray[] = "{$field} = '{$value}'";
        }

        //
        $where = count($whereArray) > 0 ? 'WHERE '.implode(' AND ', $whereArray) : '';
        $order = isset($query['order']) ? 'ORDER BY '.$query['order'] : '';
        $limit = isset($query['limit']) ? 'LIMIT '.$query['limit'] : '';
        $sql = "SELECT * FROM {$table} {$where} {$order} {$limit}";
        $results = static::getDatabase()->getResults($sql);

        //
        foreach ($results as &$record) {
            $record = static::create($record);
        }

        return $results;
    }
378819
public function insert( $query, array $data = [ ] )
    {
        $id = NULL;

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

        if ( FALSE === $statement )
        {
            $this->close();

            throw new DatabaseException( 'Failed to create prepared statement.' );
        }

        $result = $statement->execute( $data );

        $this->query = $statement->queryString;

        if ( FALSE !== $result )
        {
            $result = ( int ) $this->database->lastInsertId();
        }

        return $result;
    }
1019946
public function &getOneRow($query)
    {
        $result = $this->execute($query);
        if ( $result != false ) {
            return $result->fetch(PDO::FETCH_ASSOC);
        }
        return false;
    }
1334384
public static function getRow($query)
    {
        $ret = null;

        $res = self::query($query);
        if ($res) {
            if ($row = self::connection()->sql_fetch_assoc($res)) {
                $ret = $row;
            }
            self::free($res);
        }

        return $ret;
    }
625852
function parse_query($query) {
		$operations = array('SELECT','INSERT','UPDATE','DELETE','REPLACE','RENAME','SHOW','SET','DROP','CREATE INDEX','CREATE TABLE','EXPLAIN','DESCRIBE');

		$query_ex = '/(?P<operation>'.implode("|",$operations).')\s*(?P<columns>.?)\s*(FROM|INTO)\s*(?P<table>`?.*?`?)\s*(WHERE)?\s*?(?P<where>.*?)\s*?(ORDER BY)?\s*?(?P<order>.*?)?\s*?(LIMIT)?(?P<limit>.*?)?$/i';
		preg_match($query_ex, $query, $retn);
		return $retn;	
    }
147286
public function prepare($query)
    {
        $this->connect();
        $isObject = $query instanceof Query;
        $statement = $this->_connection->prepare($isObject ? $query->sql() : $query);
        $result = new MysqlStatement($statement, $this);
        if ($isObject && $query->isBufferedResultsEnabled() === false) {
            $result->bufferResults(false);
        }

        return $result;
    }
1319104
private function executeQuery($query) {
		$content = (string)$this->getAdapter()->get($query)->getBody();
		if (empty($content)) {
			throw new NoResult(sprintf('Could not execute query %s', $query));
		}

		$data = Xml::build($content);
		if (empty($data) || empty($data->result)) {
			throw new NoResult(sprintf('Could not execute query %s', $query));
		}

		$data = (array)$data->result;

		$adminLevels = [];

		if (!empty($data['isp']) || !empty($data['isp'])) {
			$adminLevels[] = [
				'name' => isset($data['isp']) ? $data['isp'] : null,
				'code' => null,
				'level' => 1
			];
		}

		return $this->returnResults([
			array_merge($this->getDefaults(), [
				'latitude' => isset($data['latitude']) ? $data['latitude'] : null,
				'longitude' => isset($data['longitude']) ? $data['longitude'] : null,
				'locality' => isset($data['city']) ? $data['city'] : null,
				'adminLevels' => $adminLevels,
				'country' => isset($data['countryname']) ? $data['countryname'] : null,
				'countryCode' => isset($data['countrycode']) ? $data['countrycode'] : null,
			])
		]);
	}
699382
public static function executeSingleton0(string $query)
  {
    self::logQuery($query);

    return self::$dl->executeSingleton0($query);
  }
918639
protected function executeQuery() {

		$this->lastQuerySql = $this->sql;
		return $this->dbConnection->doPreparedQuery($this->sql, $this->valuesToBind);

	}
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;
				
			}
			
		}
		
	}
270392
public function insert($query, array $data){        
        $this->conn->prepare($query)->execute($data);
        
        return $this->conn->lastInsertId();
    }
834897
public function executeQuery($sql)
    {
        $result = $this->connection->query($sql);
        $this->errno = $this->connection->errno;
        $this->error = $this->connection->error;
        if($this->connection->errno) {
            echo 'Query Error ['.$this->errno.'] : '.$this->error.' : '.$sql;
        }
        if($this->errno == 1054) {
            echo 'Table not set properly in query';
        }
        return $result;
    }
1211560
public static function executeSingleton0(string $query)
  {
    $result = self::query($query);
    $row    = $result->fetch_array(MYSQLI_NUM);
    $n      = $result->num_rows;
    $result->free();

    if (self::$mysqli->more_results()) self::$mysqli->next_result();

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

    return $row[0];
  }
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;
    }