Executes a command returning the results.

@param query {string} the query string
@param params {[]|{}} the parameters to be bound to the query
@returns {[]} an array of rows
503216
function query (query, params) {
        let rows = [];
        let stmt = sql.prepare(query);
        params = normalizeParams(params);
        stmt.bind(params);
        while(stmt.step()) {
            rows.push(stmt.getAsObject());
        }
        stmt.free();
        return rows;
    }
44261
public function executeQuery($query, array $params = []) {
        $storage = $this->getStorage();
        $cacheKey = null;
        $cacheLength = null;

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

        } else if (!is_array($query)) {
            throw new InvalidQueryException('Query must be a command array or a Titon\Db\Query instance');
        }

        // Use the storage engine first
        if ($cacheKey) {
            if ($storage && $storage->has($cacheKey)) {
                return $storage->get($cacheKey);

            // Fallback to driver cache
            // This is used to cache duplicate queries
            } else if ($this->hasCache($cacheKey)) {
                return $this->getCache($cacheKey);
            }
        }

        // Execute the query using the dialect
        $db = $this->getConnection()->selectDB($this->getDatabase());
        $dialect = $this->getDialect();
        $startTime = microtime();

        // Direct query command
        if (is_array($query)) {
            $response = $db->command($query, $params);

        // Using query object
        } else {
            if ($query->getType() === Query::CREATE_TABLE) {
                $response = $dialect->executeCreateTable($db, $query);

            } else {
                $type = $query->getType();
                $method = 'execute' . ucfirst($type);

                if (!method_exists($dialect, $method)) {
                    throw new UnsupportedQueryStatementException(sprintf('Query statement %s does not exist or has not been implemented', $type));
                }

                $response = call_user_func_array([$dialect, $method], [$db->selectCollection($query->getTable()), $query]);
            }
        }

        // Gather and log result
        if (is_array($response)) {
            $response['startTime'] = $startTime;

            if (isset($response['id'])) {
                $this->_lastID = $response['id'];
            }
        } else {
            $this->_lastID = null;
        }

        if (is_array($query)) {
            $response['command'] = $query;

            $this->_result = new MongoResultSet($response);
        } else {
            $this->_result = new MongoResultSet($response, $query);
        }

        $this->logQuery($this->_result);

        // Return and cache result
        if ($cacheKey) {
            if ($storage) {
                $storage->set($cacheKey, $this->_result, $cacheLength);
            } else {
                $this->setCache($cacheKey, $this->_result);
            }
        }

        return $this->_result;
    }
1337868
public List executeQuery(String query, EntityMetadata m, KunderaQuery kunderaQuery)
    {
        DataFrame dataFrame = getDataFrame(query, m, kunderaQuery);

        // dataFrame.show();
        return dataHandler.loadDataAndPopulateResults(dataFrame, m, kunderaQuery);
    }
1120140
protected function query($query, ...$params)
    {
        $saveParams = array_map([$this, 'quote'], $params);

        $baseSql = str_replace('{table}', $this->table, $query);
        $sql = vsprintf($baseSql, $saveParams);

        $ret = $this->server->query($sql);

        if ($ret === false) {
            trigger_error($this->server->error . " $sql", E_USER_NOTICE);
        }

        return $ret;
    }
1148551
function (params) {
        params = _.isString(params) ? QueryParam.parse(params) : params;
        this.query.populate(params);
    }
960912
function getQueryParams(params) {
        params = params || {};
        var url = $location.url();
        var idx = url.indexOf('?');

        // if there is a query string
        if (idx < 0) { return {}; }

        // get the query string and split the keyvals
        var query = url.substring(idx + 1);
        var keyVals = query.split('&');

        // put each key/val into the params object
        _.each(keyVals, function (keyVal) {
            var keyValArr = keyVal.split('=');
            params[keyValArr[0]] = keyValArr[1];
        });

        return params;
    }
1008844
public function exec($query, array $params = [])
    {
        $this->lastStatement = $this->getPDO()->prepare($query);
        $res                 = $this->lastStatement->execute($this->prepareParams($params));
        $errors              = $this->lastStatement->errorInfo();
        return $res;
    }
881809
public function query($query, array $params = [])
    {
        // Execute query
        $stmt = $this->connection->prepare($query);
        $stmt->execute($params);
        // Return result resource variable
        return $stmt;
    }
458560
function runQuery(query, connection, user) {
  const driver = drivers[connection.driver];

  const queryResult = {
    id: uuid.v4(),
    cacheKey: null,
    startTime: new Date(),
    stopTime: null,
    queryRunTime: null,
    fields: [],
    incomplete: false,
    meta: {},
    rows: []
  };

  return driver.runQuery(query, connection).then(results => {
    const { rows, incomplete } = results;
    if (!Array.isArray(rows)) {
      throw new Error(`${connection.driver}.runQuery() must return rows array`);
    }

    queryResult.incomplete = incomplete || false;
    queryResult.rows = rows;
    queryResult.stopTime = new Date();
    queryResult.queryRunTime = queryResult.stopTime - queryResult.startTime;
    queryResult.meta = getMeta(rows);
    queryResult.fields = Object.keys(queryResult.meta);

    if (debug) {
      const connectionName = connection.name;
      const rowCount = rows.length;
      const { startTime, stopTime, queryRunTime } = queryResult;

      console.log(
        JSON.stringify({
          userId: user && user._id,
          userEmail: user && user.email,
          connectionName,
          startTime,
          stopTime,
          queryRunTime,
          rowCount,
          query
        })
      );
    }

    return queryResult;
  });
}
889476
public function query($query, array $params = [])
    {
        $this->queryString = $query;
        $this->queryParams = $params;

        return $this;
    }
294168
public function run( $query, $params = array() )
	{
		$sth = $this->statement( $query, $params );
		
		$type = strtolower( substr( $query, 0, strpos( $query, ' ' ) ) );
	
		switch ( $type ) 
		{
			case 'update':
			case 'delete':
				return $sth->rowCount();
			break;
			
			case 'insert':
				return $this->driver()->connection()->lastInsertId();
			break;
		}
		
		return $sth;
	}
580344
function execute(sql, params) {

	if (0 === sql.trim().length) {
		console.error("\nNo SQL to process\n");
		yargs.showHelp();
		process.exit(1);
	}

	for (var i = 1; i < params.length; i++) {
		var a = params[i];
		if (a[0] !== '"' && a[0] !== "'") {
			if (+a == a) { // jshint ignore:line
				params[i] = +a;
			}
		}
	}

	alasql.promise(sql, params)
		.then(function (res) {
			if (!alasql.options.stdout) {
				console.log(formatOutput(res));
			}
			process.exit(0);
		}).catch(function (err) {
			let errorJsonObj = JSON.parse(JSON.stringify(err, Object.getOwnPropertyNames(err)));
			console.error(formatOutput({
				error: errorJsonObj
			}));
			process.exit(1);
		});
}
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;
	}
150114
function query(params, callback) {
  const args = utils.getArgs(params, [config], callback);
  const url = `http://${args.options.ip}:${args.options.port}/`;

  return request.get({
    url,
    qs: args.options,
  }, function(err, res, body) {
    if (err) {
      return args.callback(err);
    }
    return args.callback(null, body);
  });
}
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 );
	}
681960
private ResultSet executeQuery(Query query, String tableName, Object... values) {
        m_logger.debug("Executing statement {} on table {}.{}; total params={}",
                       new Object[]{query, m_keyspace, tableName, values.length});
        try {
            PreparedStatement prepState = getPreparedQuery(query, tableName);
            BoundStatement boundState = prepState.bind(values);
            return m_session.execute(boundState);
        } catch (Exception e) {
            String params = "[" + Utils.concatenate(Arrays.asList(values), ",") + "]";
            m_logger.error("Query failed: query={}, keyspace={}, table={}, params={}; error: {}",
                           query, m_keyspace, tableName, params, e);
            throw e;
        }
    }
1058191
protected function _fetchAll($query, $params)
    {
        $db = $this->db;
        $sth = $db->prepare($query);
        foreach ($params as $key => $val) {
            if (is_int($val)) {
                $sth->bindValue("$key", $val, $db::PARAM_INT);
            } else {
                $sth->bindValue("$key", $val);
            }
        }
        $sth->execute();
        return $sth->fetchAll($db::FETCH_ASSOC);
    }