Skip to main content
Calling execute() on a query returns a ResultsProvider object. This does not immediately process all data — results are lazy by default and only materialized when you iterate or call a fetch method.

ResultsProvider modes

execute() automatically selects the most efficient result mode, but you can override it explicitly:
Queries with JOIN or ORDER BY always use InMemory mode regardless of the explicit parameter, because those operations require full dataset access.

Fetch methods

fetchAll()

Returns a Generator that yields all result rows. Optionally maps each row to a DTO class:

getIterator()

Returns a Traversable — equivalent to fetchAll() without DTO mapping. Useful in foreach directly on the results object:

fetch()

Returns the first row only, or null if there are no results:

fetchSingle()

Returns a single field value from the first row. Dot notation is supported for nested fields:

fetchNth()

Returns every nth row as a Generator. Pass an integer for every nth row, or 'even'/'odd' for even/odd-indexed rows (0-based):

exists()

Returns true if at least one result row exists. More efficient than count() because it stops after finding the first row:

count()

Returns the total number of result rows:

Aggregate methods

These methods compute values over the result set without requiring a GROUP BY in the query:

DTO mapping

All fetch methods that return rows accept an optional class-string $dto parameter. When provided, each row is mapped to an instance of the given class using reflection.

Anonymous class DTO

Named class DTO

Constructor-based DTO

If the class has a constructor, FiQueLa maps field values to constructor parameters by name:
DTO mapping uses PHP reflection. Public properties are populated by matching field names. If a constructor is present, parameters are matched by name from the result row.

INTO — exporting results

After executing, you can pipe results directly to an output file using into():
See the FQL syntax page for the full INTO format reference.