12.6. The OpenCReport\Query class #

12.6.1. Get result for a query's current row
12.6.2. Start navigation for a query
12.6.3. Navigate to the next row
12.6.4. Navigate use previous/next row
12.6.5. Add a query follower
12.6.6. Add an N:1 query follower
12.6.7. Free a query

class OpenCReport\Query {
    public final get_result():
                     OpenCReport\QueryResult;

    public final navigate_start(): void;
    public final navigate_next(): bool;

    public final navigate_use_prev_row(): void;
    public final navigate_use_next_row(): void;

    public final add_follower(
                     OpenCReport\Query $follower):
                     bool;
    public final add_follower_n_to_1(
                     OpenCReport\Query $follower,
                     OpenCReport\Expr $match):
                     bool;

    public final free(): void;
}

12.6.1. Get result for a query's current row #

The result is OpenCReport\QueryResult. See Section 12.7.

public final
OpenCReport\Query::get_result():
                     OpenCReport\QueryResult;

12.6.2. Start navigation for a query #

Reset query (and all its followers) to go before the first row.

public final
OpenCReport\Query::navigate_start(): void;

12.6.3. Navigate to the next row #

Navigate the query to the next row and return if the new row is valid. The current row of the query's follower queries are also moved to the next valid row.

public final
OpenCReport\Query::navigate_next(): bool;

Usually queries do not have a uniform way to report the total number of rows, although some datasource types may have such a facility. Instead, they can report that the dataset has ended.

12.6.4. Navigate use previous/next row #

These functions expose an implementation detail of the data traversal in OpenCReports. There is a 3-row data cache in which there is always the current row. One past row is kept so e.g. break boundaries can be detected and there is one row read-ahead to detect the end-of-data condition early. These functions allow to switch back and forth in the 3-row data cache, making the previous or next row the "current" one momentarily. The query must always be the primary query of the report. Used by unit tests that don't use ocrpt_execute().

public final
OpenCReport\Query::navigate_use_prev_row(): bool;

public final
OpenCReport\Query::navigate_use_next_row(): bool;

Usually queries do not have a uniform way to report the total number of rows, although some datasource types may have such a facility. Instead, they can report that the dataset has ended.

12.6.5. Add a query follower #

Add a query as an 1:1 follower to the main query object. The method returns whether the call succeeded.

public final
OpenCReport\Query::add_follower(
                     OpenCReport\Query $follower):
                     bool;

Adding a circular reference between queries would fail.

12.6.6. Add an N:1 query follower #

Add a query and the matching expression as a follower to the main query object. The method returns whether the call succeeded.

public final
OpenCReport\Query::add_follower_n_to_1(
                     OpenCReport\Query $follower,
                     OpenCReport\Expr $match):
                     bool;

Adding a circular reference between queries would fail.

The call takes over ownership of the match object and it must not be explicitly freed.

12.6.7. Free a query #

public final
OpenCReport\Query::free(): void;