Executes a query
@param string $query
@return mixed
349144
public function execute($query, $args) {
		/*
		 * INITIALIZE
		 */
		
		//validate query
		if (!is_string($query) || empty($query))
			throw new \InvalidArgumentException("Query is not a valid string");

		//open connection
		$this->driver->connect();
		
		/*
		 * CACHE CONTROL
		 */
		
		$cachedValue = $resultMap = null;
		$cacheable = false; //if mapped value is cacheable
		
		//check if there is a value stored in cache with the given key
		if (array_key_exists('cache.key', $this->config) && isset($this->cacheProvider)) {
			//build cache key
			$cacheKey = (new CacheKeyFormatter($this->typeManager))->format($this->config['cache.key'], $args, $this->config);

			//check if key is present
			if ($this->cacheProvider->exists($cacheKey)) {
				$cachedValue = $this->cacheProvider->fetch($cacheKey);
				
				if (is_array($cachedValue) || is_object($cachedValue)) {
					//get cache metadata
					$cacheMeta = $this->extractCacheMetadata($this->config['cache.metakey'], $cachedValue);
					
					//no metadata, we didn't stored it
					if (is_null($cacheMeta)) 
						return $cachedValue;
					
					//create mapper instance
					$mapper = (new \ReflectionClass($cacheMeta->class))->newInstance($this->driver->buildTypeManager(), $cacheMeta->resultMap);
					
					if (!empty($cacheMeta->groups))
						$mapper->setGroupKeys($cacheMeta->groups);
					
					//build mapping callback (method tells if this is a list or a single row)
					$mappingCallback = [$mapper, $cacheMeta->method];
					
					//set resultmap (allows further processing)
					$resultMap = $cacheMeta->resultMap;
				}
				else
					return $cachedValue;
			}
		}
		
		if (is_null($cachedValue)) {
			/*
			 * GENERATE QUERY
			 */
				
			//build statement
			$stmt = $this->driver->buildStatement($this->typeManager)->format($query, $args, $this->config);
			
			//debug query
			if (array_key_exists('callback.debug', $this->config)) 
				call_user_func($this->config['callback.debug'], $stmt);
			
			/*
			 * PARSE MAPPING EXPRESSION
			 */
	
			//build mapping callback
			if (array_key_exists('map.type', $this->config)) {
				//get mapping type
				$mappingType = $this->config['map.type'];
				
				//object mapping type: object, object:class, object[column], object[column:type], etc
				if (preg_match(self::OBJECT_TYPE_REGEX, $mappingType, $matches)) {
					//get class, if any
					if (empty($matches[1])) { //no class defined, use default
						$defaultClass = 'stdClass';
						$resultMap = array_key_exists('map.result', $this->config) ? $this->config['map.result'] : null; //obtain result map
						$mapper = new StdClassMapper($this->typeManager, $resultMap);
					}
					else {
						//remove leading ':'
						$defaultClass = strtolower($matches[1]);
						$resultMap = array_key_exists('map.result', $this->config) ? $this->config['map.result'] : null;
						
						//get mapping class
						if ($defaultClass == 'stdclass')
							$mapper = new StdClassMapper($this->typeManager, $resultMap);
						elseif ($defaultClass == 'arrayobject')
							$mapper = new ArrayObjectMapper($this->typeManager, $resultMap);
						elseif (Profiler::getClassProfile($matches[1])->isEntity()) { //check if defined class is an entity
							$mapper = new EntityMapper($this->typeManager, $matches[1]);
							$resultMap = $matches[1];
						}
						else {
							$mapper = new ObjectMapper($this->typeManager, $matches[1]);
							$resultMap = null;
						}
					}
					
					//generate a new object mapper object
					$group = $groupType = $index = $indexType = null;
					
					if (count($matches) > 2) {
						$mappingCallback = [$mapper, 'mapList'];
					
						//obtain group
						if (array_key_exists('callback.group', $this->config)) {
							$group = $this->config['callback.group'];
							$groupType = 'callable';
						}
						elseif (isset($matches[2]) && ($matches[2] == '0' || !empty($matches[2]))) {
							$group = $matches[2];
							$groupType = (isset($matches[3]) && !empty($matches[3])) ? $matches[3] : null;
						}
					
						//obtain index
						if (array_key_exists('callback.index', $this->config)) {
							$index = $this->config['callback.index'];
							$indexType = 'callable';
						}
						elseif (isset($matches[5]) && ($matches[5] == '0' || !empty($matches[5]))) {
							$index = $matches[5];
							$indexType = (isset($matches[6]) && !empty($matches[6])) ? $matches[6] : null;
						}
					
						//add index and group to mapper parameters
						$mappingParams = [$index, $indexType, $group, $groupType];
					}
					else
						$mappingCallback = [$mapper, 'mapResult']; //set default method
				}
				//array mapping type: array, array[], array[column], array[column:type]
				elseif (preg_match(self::ARRAY_TYPE_REGEX, $mappingType, $matches)) {
					//obtain result map
					$resultMap = array_key_exists('map.result', $this->config) ? $this->config['map.result'] : null;
						
					//generate a new array mapper object
					$mapper = new ArrayMapper($this->typeManager, $resultMap);
					
					if (count($matches) > 1) {
						$mappingCallback = [$mapper, 'mapList'];
						$group = $groupType = $index = $indexType = null;
					
						//obtain group and group type
						if (array_key_exists('callback.group', $this->config)) {
							$group = $this->config['callback.group'];
							$groupType = 'callable';
						}
						elseif (isset($matches[1]) && ($matches[1] == '0' || !empty($matches[1]))) {
							$group = $matches[1];
							$groupType = (isset($matches[2]) && !empty($matches[2])) ? $matches[2] : null;
						}
					
						//obtain index and index type
						if (array_key_exists('callback.index', $this->config)) {
							$index = $this->config['callback.index'];
							$indexType = 'callable';
						}
						elseif (isset($matches[4]) && ($matches[4] == '0' || !empty($matches[4]))) {
							$index = $matches[4];
							$indexType = (isset($matches[5]) && !empty($matches[5])) ? $matches[5] : null;
						}
							
						//add index and group to mapper parameters
						$mappingParams = [$index, $indexType, $group, $groupType];
					}
					else
						$mappingCallback = [$mapper, 'mapResult'];
				}
				//simple mapping type: integer, string, float, etc
				elseif (preg_match(self::SIMPLE_TYPE_REGEX, $mappingType, $matches)) {					
					//get type handler
					$typeHandler = $this->typeManager->getTypeHandler($matches[1]);
					
					if ($typeHandler === false)
						throw new \InvalidArgumentException("Unknown type '{$matches[1]}'");
						
					//create mapper instance
					$mapper = new ScalarTypeMapper($typeHandler);
						
					//set mapping callback
					$mappingCallback = [$mapper, empty($matches[2]) ? 'mapResult' : 'mapList'];
				}
				else
					throw new \InvalidArgumentException("Unrecognized mapping expression '$mappingType'");
			}
			else {
				//obtain result map
				$resultMap = array_key_exists('map.result', $this->config) ? $this->config['map.result'] : null;
					
				//generate mapper
				$mapper = new ArrayMapper($this->typeManager, $resultMap);
					
				//use default mapping type
				$mappingCallback = [$mapper, 'mapList'];
				
				//check for group callback
				if (array_key_exists('callback.group', $this->config)) {
					$group = $this->config['callback.group'];
					$groupType = 'callable';
				}
				else
					$group = $groupType = null;
				
				//check for index callback
				if (array_key_exists('callback.index', $this->config)) {
					$index = $this->config['callback.index'];
					$indexType = 'callable';
				}
				else
					$index = $indexType = null;
				
				$mappingParams = [$index, $indexType, $group, $groupType];
			}
			
			/*
			 * EXECUTE QUERY
			 */
				
			//run query
			$result = $this->driver->query($stmt);
				
			//check query execution
			if ($result === false)
				$this->driver->throwQueryException($stmt);
			
			//check if result is successful
			if ($result === true) {
				//free result
				$this->driver->freeResult($result);
				return true;
			}
			
			/*
			 * INVOKE EMPTY RESULT CALLBACK
			 */
				
			$ri = $this->driver->buildResultIterator($result);
				
			//check if result is empty
			if ($ri->countRows() === 0) {
				if (array_key_exists('callback.empty', $this->config))
					return call_user_func($this->config['callback.empty'], $result);
			}
			else
				$cacheable = true;
			
			/*
			 * ADD CUSTOM MAPPING OPTIONS
			 */
				
			//add defined mapping parameters
			if (array_key_exists('map.params', $this->config)) {
				if (!empty($mappingParams))
					$mappingParams = array_merge($mappingParams, $this->config['map.params']);
				else
					$mappingParams = $this->config['map.params'];
			}
				
			//build mapping callback parameters
			if (isset($mappingParams))
				array_unshift($mappingParams, $ri);
			else
				$mappingParams = [$ri];
			
			/*
			 * MAP RESULT
			 */
				
			//call mapping callback
			$mappedResult = call_user_func_array($mappingCallback, $mappingParams);
				
			//free result
			$this->driver->freeResult($result);
			
			/*
			 * CACHEABLE ATTRIBUTES
			 */
			
			if (isset($resultMap)) {
				$copy = $this->__copy(); //clone current instance
				
				if ($mappingCallback[1] == 'mapList') { //list of rows
					if ($mapper->hasGroupKeys()) { //grouped
						foreach ($mapper->getGroupKeys() as $group) {
							foreach (array_keys($mappedResult[$group]) as $k)
								$mapper->evaluateAttributes($mappedResult[$group][$k], $copy);
						}
					}
					else { //list
						foreach (array_keys($mappedResult) as $k)
							$mapper->evaluateAttributes($mappedResult[$k], $copy);
					}
				}
				else //single row
					$mapper->evaluateAttributes($mappedResult, $copy);
			}
			
			/*
			 * CACHE STORE
			 */
			
			//check if obtained value can be stored
			if (isset($this->cacheProvider) && $cacheable) {
				//build value wrapper
				if ($mapper instanceof ComplexMapper)
					$this->injectCacheMetadata($this->config['cache.metakey'], $mappedResult, get_class($mapper), $mappingCallback[1], $mapper->getGroupKeys(), $resultMap);
				
				//store value
				if (array_key_exists('cache.ttl', $this->config))
					$this->cacheProvider->store($cacheKey, $mappedResult, intval($this->config['cache.ttl']));
				else
					$this->cacheProvider->store($cacheKey, $mappedResult);
			}
		}
		
		/*
		 * DYNAMIC ATTRIBUTES
		 */

		if (!empty($resultMap) && $this->config['depth.limit'] > $this->config['depth.current']) {
			$icopy = $this->__icopy();			
			
			if ($mappingCallback[1] == 'mapList' && !empty($mappedResult)) {
				if ($mapper->hasGroupKeys()) {
					foreach ($mapper->getGroupKeys() as $group) {
						foreach (array_keys($mappedResult[$group]) as $k) {
							$mapper->evaluateDynamicAttributes($mappedResult[$group][$k], $icopy);
							$mapper->evaluateAssociations($mappedResult[$group][$k], $icopy);
						}
					}
				}
				else {
					foreach (array_keys($mappedResult) as $k) {
						$mapper->evaluateDynamicAttributes($mappedResult[$k], $icopy);
						$mapper->evaluateAssociations($mappedResult[$k], $icopy);
					}
				}
			}
			elseif ($mappingCallback[1] != 'mapList' && !is_null($mappedResult)) {
				$mapper->evaluateDynamicAttributes($mappedResult, $icopy);
				$mapper->evaluateAssociations($mappedResult, $icopy);
			}
		}
		
		/*
		 * TRAVERSING CALLBACK
		 */
		
		if (array_key_exists('callback.each', $this->config)) {
			$eachCallback = $this->config['callback.each'];
			$copy = isset($copy) ? $copy : $this->__copy();
		
			if ($eachCallback instanceof \Closure) {
				//check if mapped result is a list
				if ($mappingCallback[1] == 'mapList' && !empty($mappedResult)) {
					if ($mapper instanceof ComplexMapper && $mapper->hasGroupKeys()) {
						foreach ($mapper->getGroupKeys() as $group) {
							foreach (array_keys($mappedResult[$group]) as $k)
								$eachCallback->__invoke($mappedResult[$group][$k], $copy);
						}
					}
					else {
						foreach (array_keys($mappedResult) as $k)
							$eachCallback->__invoke($mappedResult[$k], $copy);
					}
				}
				elseif (!is_null($mappedResult))
					$eachCallback->__invoke($mappedResult, $copy);
			}
			else {
				//this closure avoids getting "expected to be a reference"-style messages
				$c = function (&$mappedResult) use ($eachCallback) {
					call_user_func($eachCallback, $mappedResult, $copy);
				};
		
				//call traverse callback
				if ($mappingCallback[1] == 'mapList' && !empty($mappedResult)) {
					if ($mapper instanceof ComplexMapper && $mapper->hasGroupKeys()) {
						foreach ($mapper->getGroupKeys() as $group) {
							foreach (array_keys($mappedResult[$group]) as $k)
								$c->__invoke($mappedResult[$group][$k]);
						}
					}
					else {
						foreach (array_keys($mappedResult) as $k)
							$c->__invoke($mappedResult[$k]);
					}
				}
				elseif (!is_null($mappedResult))
					$c->__invoke($mappedResult);
			}
		}
		
		/*
		 * FILTER CALLBACK
		 */
		
		//apply filter
		if (array_key_exists('callback.filter', $this->config)) {
			$filterCallback = $this->config['callback.filter'];
		
			//check if mapped result is a list
			if ($mappingCallback[1] == 'mapList' && !empty($mappedResult)) {
				if ($mapper instanceof ComplexMapper && $mapper->hasGroupKeys()) {
					foreach ($mapper->getGroupKeys() as $group)
						$mappedResult[$group] = array_filter($mappedResult[$group], $filterCallback);
				}
				else
					$mappedResult = array_filter($mappedResult, $filterCallback);
			}
			elseif (!is_null($mappedResult)) {
				if (!call_user_func($filterCallback, $mappedResult))
					$mappedResult = null;
			}
		}
		
		return $mappedResult;
	}
568268
public function query($query)
    {
        $this->errorInfo = null;
        $this->errorCode = null;
        $query = trim(strtolower($query));
        if ($query === 'show tables') {
            $data = array();
            foreach ($this->tables as $k => $table) {
                $data[] = array('name' => $k);
            }
            return new Cursor($data);
        }
        $this->errorInfo = 'Invalid query';
        $this->errorCode = self::ERROR_QUERY;
    }
676434
public function exec($query)
    {
        if ($this->isConnected()) {
            try {
                return $this->pdo->exec($query);
            } catch (PDOException $e) {
                throw new \Exception($e->getMessage());
                return false;
            }
        } else {
            return false;
        }
    }
434699
public function executeRows(string $query): array
  {
    $result = $this->query($query);
    if ($this->haveFetchAll)
    {
      $ret = $result->fetch_all(MYSQLI_ASSOC);
    }
    else
    {
      $ret = [];
      while (($row = $result->fetch_assoc()))
      {
        $ret[] = $row;
      }
    }
    $result->free();

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

    return $ret;
  }
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;
    }
1277561
public function exec($query)
    {
        $stmt = $this->getWye()->makeStatement($query, []);

        $stmt->execute();

        return $stmt->rowCount() !== null ? $stmt->rowCount() : 0;
    }
108590
private function executeQuery($query, $data = null) {
        $stmt = $this->conn->prepare($query);
        $stmt->execute($data);
        
        return $stmt;
    }
134501
public function parse($query=null)
    {
        $this->checkQuery($query);
        
        return $this->getDb()->setQuery($this->getQuery())->parse();
    }
465071
public function executeNone(string $query): int
  {
    $this->realQuery($query);

    $n = $this->mysqli->affected_rows;

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

    return $n;
  }
381487
protected function executeQuery($query)
    {
        $query   = null !== $this->getLocale() ? sprintf('%s&language=%s', $query, $this->getLocale()) : $query;
        $content = $this->getAdapter()->get($query)->getBody();

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

        if (!isset($data['Response']) && 'InvalidCredentials' === $data['subtype']) {
            throw new InvalidCredentials(sprintf('Invalid credentials: %s', $data['details']));
        } elseif (!isset($data['Response'])) {
            throw new NoResult(
                sprintf('Error type `%s` returned from api `%s`', $data['subtype'], $data['Details'])
            );
        }

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

        $locations = $data['Response']['View'][0]['Result'];

        $results = array();
        foreach ($locations as $location) {
            $location       = $location['Location'];
            $coordinates    = isset($location['NavigationPosition'][0]) ? $location['NavigationPosition'][0] : $location['DisplayPosition'];
            $bounds         = $location['MapView'];
            $address        = $location['Address'];
            $additionalData = $location['Address']['AdditionalData'];

            $results[] = array_merge($this->getDefaults(), array(
                'latitude'     => $coordinates['Latitude']  ?: null,
                'longitude'    => $coordinates['Longitude'] ?: null,
                'bounds'       => array(
                    'south' => $bounds['BottomRight']['Latitude']  ?: null,
                    'west'  => $bounds['TopLeft']['Longitude']     ?: null,
                    'north' => $bounds['TopLeft']['Latitude']      ?: null,
                    'east'  => $bounds['BottomRight']['Longitude'] ?: null,
                ),
                'streetNumber' => isset($address['HouseNumber']) ? $address['HouseNumber'] : null,
                'streetName'   => isset($address['Street'])      ? $address['Street']      : null,
                'city'         => isset($address['City'])        ? $address['City']        : null,
                'cityDistrict' => isset($address['District'])    ? $address['District']    : null,
                'zipcode'      => isset($address['PostalCode'])  ? $address['PostalCode']  : null,
                'county'       => isset($address['County'])      ? $address['County']      : null,
                'regionCode'   => isset($address['State'])       ? $address['State']       : null,
                'countryCode'  => isset($address['Country'])     ? $address['Country']     : null,
                'region'       => $this->findByKey('StateName', $additionalData),
                'country'      => $this->findByKey('CountryName', $additionalData),
                'countyCode'   => null,
            ));
        }

        return $results;
    }
961702
function executeNonQuery($query) {

        try {
            $connection = $this->getConnection();

            if (!mysql_query($query, $connection)) {
                mysql_close($connection);
                throw new \Exception("SQL Error: " . mysql_error());
            }

            mysql_close($connection);
        } catch (\Exception $pEx) {
            throw new \Exception("Fallo al ejecutar la query: " . $query . $pEx->getMessage());
        }
    }
373750
public function query($query) {

        if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
            return $this->connection->ExecQuery($query);
        } else {
            $execString = $this->connectionString . '"' . $query . '"';
            $aReturn = Array();
            $inc = $wmiout = $execstatus = null;
            exec($execString, $wmiout, $execstatus);
            $wmiCount = count($wmiout);

            if ($wmiCount > 0) {
                $names = explode('|', $wmiout[1]); // build the names list to dymanically output it
                for ($i = 2; $i < $wmiCount; $i++) { // dynamically output the key:value pairs to suit cacti
                    $data = explode('|', $wmiout[$i]);
                    $j = 0;
                    $inc = $i - 2;
                    $aReturn[$inc] = new \stdClass();
                    foreach ($data as $item) {
                        $jIndex = $j++;
                        if (isset($names[$jIndex])) {
                            $objName = $names[$jIndex];
                            $aReplace = array(':', '_', '  ', '   ', '    ', '     ', '      ', '       ', '        ', '         ', '          ', '           ', '            ');
                            $aReplace2 = array('(null)', 'True', 'False');
                            $preparedData = str_replace($aReplace2, array(null, true, false), str_replace($aReplace, ' ', $item));

                            $aReturn[$inc]->$objName = $preparedData;
                        } else {
                            $j = $jIndex - 1;
                        }
                    }
                }
            }
            $stdObjReturn = (object) $aReturn;

            return $stdObjReturn;
        }
    }
459998
protected function executeDatabaseQuery($query)
    {
        $database = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();

        $database->execute($query);
    }
883979
public function query($query = null)
    {
        /** @var StmtInterface $result */
        try {
            
            $event = new ConnectionEvent($this, $query);
            $this->container->getDispatcher()->dispatch(ConnectionEvent::ON_QUERY, $event);
            
            $result = parent::query($query);
        } catch (\Exception $exception) {
            throw new ConnectionException(sprintf(
                'Executing SQL Query was failure with error: [%d] (%s)', $exception->getCode(), $exception->getMessage()));
        }
        
        return $result;
    }
954997
public function execute($query, $bindings = [])
    {
        if (strtolower(substr($query, 0, 6)) === "select" && $this->forcePrefix) {
            $query = $this->forcePrefix . $query;
        }

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

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

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

            $statement->execute();
            return $statement;
        });
    }
384015
public static function execInsert($query)
    {
        $ret = false;

        $res = self::query($query);

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

        return $ret;
    }
1157552
public function runRequest($query)
    {
        $request = Yii::createObject([
            'class'  => Request::class,
            'params' => is_array($query) ? $query : array_filter(explode(' ', $query)),
        ]);

        return Yii::$app->handleRequest($request);
    }