Collections
A Collection is a wrapper class for models.
It always contains at least one Model.
If no rows were found, the return value is null instead of an empty Collection.
Fetching rows
If you want to fetch more than one row from the database, you can use the static method findBy() which returns a Collection.
findBy() expects two parameters. The first is the column of the table, the second is its value.
Like for models, you can use late static binding and add the column to the method name.
A third parameter for options is optional.
For more complex conditions, optionally pass arrays as parameters:
Collection specific methods
findAll()
findAll() returns all rows of a table:
findMultipleByIds()
You can create a collection by passing the IDs to this method:
Data access
You can loop through a collection object using foreach.
In this example, $page is a PageModel.
You can fetch one or all columns of each row: