Writing own queries

From Sunhill Framework Documentation

When writing own Queries, first check if you could use one of the predefined queries:

If not, your own queries have to be derrived from BasicQuery and some abstract methods have to be overwritten:

Methods

assembleQuery()

This method takes no parameters and builds an internal query structure that could be used to perform the finalizing methods on. The method can return whatever you want you just have to make sure that the remaining abstract methods can use this result to return the desired value or action.

doGetCount($assembled_query)

This function takes the result of the previous function assembleQuery() and uses it to count the number of records that match the given criteria.

doGet($assembled_query, $fields)

This function returns (depending on fields) all records or only certain fields that result of the $assmbled_query. Note: All elements of the Collection are automatically passed through the getRecord() method to return the standardized result, so you mustn't call getRecord() in the method doGet().

fieldExists(string $field): bool

Returns if the given $field exists as a field or a pseudo field.

fieldOrderable(string $field): bool

Returns if the given $field is usable as a sorting key in orderBy().

getRecord($record)

This method does not have to necessarily be overwritten. By default it just return $record. In some cases it is necessary to return another type (e.g. Object).

doDelete($assembled_query): int

doUpdate($assembled_query, array $fields): int

doInsert($assembled_query, array $fields)

Static data structures