Perform a query, return the first row

@param string sql
@param vararg arguments (for sprintf)
@return array
172066
protected function query_row_assoc ( $sql )
	{
		$sql = $this->sql_printf(func_get_args());
		$result = $this->query_all_assoc($sql);
		$val = array_pop($result);
		return $val;
	}
894618
final public function query (string $sql)
	{
		static::$lastQuery 	= $sql;
		$result 			= mysqli_query($this->connection, $sql);
		$this->confirmQuery($result);
		return $result;
	}
945921
public <T> List<T> query(String sql, Class<T> beanClass, Object... params) throws SQLException {
		return query(sql, new BeanListHandler<T>(beanClass), params);
	}
433189
public function getRow($sql, array $args = [])
    {
        $query = $this->query($sql, $args);
        if (!$query) {
            return [];
        }
        
        $rs = $query->fetch(\PDO::FETCH_ASSOC);
        return $rs;
    }
1356111
public function query(string $sql): ?array
    {
        $conn = $this->dbUtils->getConn();
        $sql = trim($sql);
        try {
            $res = $conn->query($sql);
            if (strpos($sql, 'SELECT') === 0) {
                return $res->fetchAll();
            }

            return null;
        } catch (\Exception $e) {
            throw new NeuralyzerException($e->getMessage());
        }
    }
34970
public static function read($sql, $mode = self::KEY)
    {
        $vals = [];
        $result = self::query($sql);
        while ($row = $result->fetch($mode)) {
            $vals[] = $row;
        }
        //
        return $vals;
    }
488938
public List<Object> querySingleRowResults(String sql, String[] args) {
		return db.querySingleRowResults(sql, args);
	}
829512
function fetch_arrays($sql)
    {
        $rs   = $this->query($sql);
        $data = [];
        while (true == ($row = $rs->fetch_assoc())) {
            $data[] = $row;
        }
        $rs->free();
        return $data;
    }
1367221
public function query(string $sql, $par = null) : ResultInterface
    {
        $par = isset($par) ? (is_array($par) ? $par : [$par]) : [];
        if (strpos($sql, '??') && count($par)) {
            list($sql, $par) = $this->expand($sql, $par);
        }
        return $this->prepare($sql)->execute($par);
    }
1049639
protected function query($conn, $sql)
    {
        $items = array();
        if ($conn instanceof PDO) {
            $result = $conn->query($sql);
            if ($result) {
                foreach ($result as $row) {
                    $items[] = $row[0];
                }
            }
        } elseif (is_resource($conn)) {
            $result = sqlsrv_query($conn, $sql);
            if ($result) {
                while ($row = sqlsrv_fetch_array($result, SQLSRV_FETCH_NUMERIC)) {
                    $items[] = $row[0];
                }
            }
        }
        return $items;
    }
265705
protected function query_all_assoc ( $sql )
	{
		$sql = $this->sql_printf(func_get_args());
		$result = array();

		try 
		{
			$stmt = $this->conn->query($sql);
			
			$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
		}
		catch (PDOException $e) 
		{
			$this->sql_errcheck($sql);
		}
		return $result;
	}
435408
public function queryValues(string $sql, string $key): array
    {
        $result = [];
        $statement = $this->query($sql);
        while ($row = $statement->fetch(PDO::FETCH_ASSOC)) {
            $result[] = $row[$key];
        }

        return $result;
    }
1358744
protected function query_row ( $sql )
    {
        $sql = $this->sql_printf(func_get_args());
        if (!($res = pg_query($this->conn, $sql)))
        {
            $this->sql_errcheck($sql);
        }
        if ($row = pg_fetch_array($res))
        {
            $rs = $row;
        }
        else
        {
            $rs = false;
        }
        pg_free_result($res);
        return $rs;
    }
586252
public function query($sql, $data = [])
     {
         $this->_init();

         try {
             $q = $this->db->prepare($sql);
         } catch (PDOException $e) {
             throw new Exception($e->getMessage());
         }

         foreach ($data as $k => $v) {
             $$k = $v;
             $q->bindParam(':' . $k, $$k); # bindParam( ... , PDO::PARAM_INT ...);
         }

         $result = $q->execute();

         if (strpos(trim(strtoupper($sql)), 'SELECT') === 0) {
             $rows = [];
             while($row = $q->fetch()) {
                 $rows[] = $row;
             }
             return $rows;
         }

         return $result;
     }
1290138
public function query($sql)
    {
        try {
            $start = microtime(true);

            $result = $this->prepare($sql);
            $this->execute($result);

            if ($this->saveAffectedRows($result) === 0 && $this->isResult($result) && ! $this->isSelectQuery($sql)) {
                $result = true;
            }
            $this->getConnect()->logQuery($sql, [], $this->getElapsedTime($start));
        } catch (\Exception $exception) {
            $this->lastError = $this->isResult($result) ? $result->errorInfo() : [];
            $code = $this->isResult($result) ? $result->errorCode() : '';
            $this->lastErrorNo = $this->isResult($result) ? (empty($code) ? $exception->getCode() : $code) : '';
            throw (new Exceptions\QueryException($exception->getMessage(), $exception->getCode()))
                ->setQuery($sql);
        }

        return $result;
    }
792087
public function get($sql, $params = array(), $style = PDO::FETCH_ASSOC) {
		$statement = $this->query($sql, $params);

		$results = [];

		while ($row = $statement->fetch($style)) {
			$results[] = $row;
		}

		return $results;
	}
871761
protected function get_row( $query, $vars = '' ) {
		$query = $this->make_query( func_get_args() );
		return $this->db->get_row( $query );
	}