Evaluate query via middleware

@param string $query
@param array $params
@return ExecutionResult|array Result as either source object result, or serialised as array.
976018
public function queryAndReturnResult($query, $params = [])
    {
        $schema = $this->schema();
        $context = $this->getContext();

        $last = function ($schema, $query, $context, $params) {
            return GraphQL::executeQuery($schema, $query, null, $context, $params);
        };

        return $this->callMiddleware($schema, $query, $context, $params, $last);
    }
1042675
public function multiquery($query, $params = []) {

		if(true === is_array($query)) {
			$query = implode(";\n", $query);
		}

		if(false === is_string($query)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string or array, "%s" given', __METHOD__, gettype($query)), E_USER_ERROR);
		}

		$results = new ResultSet([], 'array');

		if(null === $this -> connection) {
			$this -> connect();
		}

		//Escape paramaters
		$query = $this -> escapeSql($query, $params);

		if($this -> connection -> multi_query($query)) {

			$array = [];

			do {

				if($result = $this -> connection -> use_result()) {

					while($row = $result -> fetch_array(MYSQLI_ASSOC)) {
						$array[] = $row;
					}

					$result -> close();
					$results -> append($array);
					$array = [];
				}
			}

			while($this -> connection -> more_results() && $this -> connection -> next_result());
		}

		return $results;
	}
1320429
public function delete($query, array $params = [])
    {
        $stmt = $this->connection->prepare($query);
        $stmt->execute($params);
        return $stmt->rowCount();
    }
1080838
final public static function getObjectsByQuery($query, $params=[]) {
		
		$app	= Application::getInstance();
		$db		= Database::getInstance();
		$class	= get_called_class();

		// run query
		$db->setQuery($query);
		$list = $db->loadObjectList($params);
		
		// array that returns and custom binds
		$objects = [];
		$customBinds = [];
		
		if (is_array($list) and isset($list[0])) {
			
			$binds = $class::getBinds();
			
			// get object properties from query
			$fields  = get_object_vars($list[0]);

			// search for custom field names
			foreach ($fields as $field=>$value) {
				if (!array_search($field, $binds)) {
					$customBinds[Utilities::getCamelCase($field)] = $field;
				}
			}

			// build each object
			foreach ($list as $row) {
				
				$object = new $class($row);

				// populate custom properties
				foreach ($customBinds as $customProp=>$customField) {
					$object->$customProp = $row->$customField;
				}
				
				// turn on loaded-from-db flag
				$object->loadedFromDb = TRUE;

				$objects[] = $object;
				
			}
			
		}
		
		$app->logEvent('Loaded ' . count($objects) . ' ' . $class . ' objects with custom fields ' . implode(',', $customBinds));
		
		return $objects;
		
	}
261708
public function get_all($query, $params = []) {
		$statement = $this->get_statement($query, $params);
		$statement->execute();
		return $statement->fetch_assoc();
	}
346283
public function fetch( $query, $params = array(), $arguments = array( 'obj' ) )
	{
		$sth = $this->statement( $query, $params );
		
		$args = null;
		
		foreach( $arguments as $argument )
		{
			$args |= constant( "\PDO::FETCH_".strtoupper( $argument ) );
		}
				
		return $sth->fetchAll( $args );
	}
686562
public static function run($query, $params=array()) {
		
		$self = static::getInstance();
		
		$self->openConnection();
		
		$ret = NULL;
		
		try {
			
			// prepare query
			$stat = $self->handler->prepare($query);

			// bind parameters
			$stat->execute((array)$params);

			// count affected rows
			$affected = $stat->rowCount();
			
		} catch (\PDOException $e) {
			
			// logger
			$self->logParamQuery($query, 0, $params);
			
			switch ($e->getCode()) {
				
				// integrity constraint violation
				/*
				 case '23000':
					 $message = 'Database integrity constraint violation';
					 break;
				 */
				default:
					$message = $e->getMessage();
					break;
			}
			
			$self->addError($message);
			
			$affected = 0;
			
		} catch (\Exception $e) {
			
			// logger
			$self->logParamQuery($query, 0, $params);
			$self->addError($e->getMessage());
			$affected = 0;
			
		}
		
		$stat->closeCursor();
		$self->logParamQuery($query, $affected, $params);
		
		return $affected;
			
	}
1192202
public boolean execute(Map<String, String> params, String query) {
        final AtomicBoolean result = new AtomicBoolean(false);
        Tuple2<DataSource, Connection> conn = null;
        try {
            conn = getConnection();
            NamedParameterJdbcTemplate jdbcTemplate = new NamedParameterJdbcTemplate(conn._1());
            jdbcTemplate.execute(query, params, new PreparedStatementCallback<Void>() {
                @Override
                public Void doInPreparedStatement(PreparedStatement ps) {
                    try {
                        result.set(ps.execute());
                    } catch(SQLException e) {
                        result.set(false);
                    }
                    return null;
                }
            });
        } catch (Exception ex) {
            Logger.getLogger(MysqlAccessor.class.getName()).log(Level.SEVERE, null, ex);
            result.set(false);
        } finally {
            returnConnection(conn);
        }
        return result.get();
    }
774264
public function insert($query, $params = array())
    {
        $this->_testQueryStarts($query, 'insert');
        return $this->_executeQuery($query, $params, true);
    }
1046793
public function prepareQuery($query = null, array $params = [])
    {
        /** @var StmtInterface $stmt */
        $stmt = parent::prepare($query);
        
        if (count($params) > 0) {
            $stmt->bindParams($params);
        }
        
        return $stmt;
    }
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;
    }
1244409
public function query($query, $params = null, $fetchResult = false)
        {
            $this->checkConnection(true);
            $this->log('Query: ' . $query);

            if(!empty($params)) {
                $this->log('Params: ' . print_r($params, true));
            }
            $start =  microtime(true);

            if(empty($params)) {
                $res = $this->executeQuery($query);
            } else {
                $res = $this->executePreparedStatement($query, $params);
            }

            $end = microtime(true);
            $this->log("Execution time: " . ($end - $start) . " seconds");


            if($fetchResult) {
    	        $this->log('Num Rows: '.odbc_num_rows($res));
                $resutlSet = $this->getRows($res);
                odbc_free_result($res);
                $res = $resutlSet;
                $resultSet = null;
                $fetch = microtime(true);
                $this->log("Fetch time: " . ($fetch - $end) . " seconds");
            }
            return $res;
        }
1312270
public function query($query, $params = array())
  {
    $curl = new Curl();
    $params['key'] = $this->server_key;
    $result = json_decode($curl->call(self::GOOGLEPLUS_API_URL . trim($query, '/') . '?' . http_build_query($params), array(), 'GET', true), true);
    if(!isset($result['error'])) {
      return $result;
    }
    return $this->debug_mode ? $result['error']['message'] : null;
  }
609752
public function executeQuery($query, array $params = []) {
        $this->connect();

        $cacheKey = null;
        $cacheLength = null;

        // Determine cache key and lengths
        if ($query instanceof Query) {
            $cacheKey = $query->getCacheKey();
            $cacheLength = $query->getCacheLength();

        } else if (!is_string($query)) {
            throw new InvalidQueryException('Query must be a raw SQL string or a Titon\Db\Query instance');
        }

        // Execute and return result
        return $this->_result = $this->cacheQuery($cacheKey, function(AbstractPdoDriver $driver) use ($query, $params) {
            $isQuery = ($query instanceof Query);

            // Prepare statement and bind parameters
            if ($isQuery) {
                $statement = $driver->buildStatement($query);
                $binds = $driver->resolveParams($query);

            } else {
                $statement = $driver->getConnection()->prepare($query);
                $binds = [];

                foreach ($params as $value) {
                    $binds[] = [$value, $driver->resolveType($value)];
                }
            }

            foreach ($binds as $i => $value) {
                $statement->bindValue($i + 1, $value[0], $value[1]);
            }

            $statement->params = $binds;

            // Gather and log result
            if ($isQuery) {
                $result = new PdoResultSet($statement, $query);
            } else {
                $result = new PdoResultSet($statement);
            }

            $driver->logQuery($result);

            return $result;
        }, $cacheLength);
    }
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;
    }
619195
public function row($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);
        return $this->sQuery->fetch($fetchmode);
    }
1288644
public function executeWrite(QueryInterface $query, array $params = [])
    {
        $result = $this->mysqlEmulator->getResult($query);

        if ($result) {
            return $result;
        }

        return $this->vitess->executeWrite($query, $params);
    }