Skip to content

Version 5.0.0

Choose a tag to compare

@visavi visavi released this 28 Jul 21:44
· 12 commits to master since this release

A model is no longer the record it reads. The library is now three things — a
model that declares the table, a query that reads it and a record that holds the
values. Requires PHP 8.5.

Breaking

  • Builder is gone, replaced by Model, Query and Record. A model no
    longer doubles as the row it returns, refresh() on a record is now fresh().
  • Relations declare their return type. Only a method returning Relation
    counts as one, so reading a property never runs something else.
  • Patterns are methods: whereLike(), whereNotLike(), orWhereLike(),
    orWhereNotLike(). The like operator is no longer accepted by where(), and
    an unknown operator throws instead of quietly matching nothing.
  • Sorting takes SortOrder, SORT_ASC and SORT_DESC are gone.
  • Pagination is rebuilt and no longer reads $_GET. CollectionPaginate is
    replaced by Pagination and SimplePagination; the page number is passed in:
    paginate(10, $page).
  • Migrations are written as a chain, createTable() and changeTable() no
    longer take a closure.
  • A broken cast is an error: a column cast to array or object that does
    not hold json throws instead of reading back as null.
  • Collection lost key(), next() and current().
  • The csv escape character is gone. Files follow RFC 4180: a quote inside a
    value is doubled, nothing is escaped with a backslash. A table written by 4.x
    whose values end in a backslash may read differently — check such tables
    before upgrading.

Added

cursor(), simplePaginate(), constrain() on relations, Record::toArray(),
Collection::keyBy(), and pagination that renders through a template of your own.

Fixed

Writes are atomic and locked, a relation keeps the result its record came from,
count() no longer counts the first row twice, overlapping reads no longer cut
each other short, first() honours offset().

Performance

On 50 000 rows a sorted page holds the page, not the table — 0.6 MB against
33 MB, faster than the same work on plain fopen and fgetcsv. cursor() holds
one record at a time; inserts no longer collect the keys of the table, updates
and deletes no longer read the file twice.

Full changelog with before/after examples: CHANGELOG.md