@@ -1588,8 +1588,8 @@ retrieved via the ``getErrors`` method.
15881588Pagination
15891589##########
15901590
1591- Using the ``paginate `` method, you can perform a basic pagination with all the
1592- data in a table.
1591+ Using the ``paginate `` method, you can perform pagination with all the data in
1592+ a table.
15931593
15941594Below, we take the first 30 items from the table:
15951595
@@ -1599,6 +1599,38 @@ Below, we take the first 30 items from the table:
15991599 $perPage = 30;
16001600 $data = $model->paginate($page, $perPage); // array
16011601
1602+ Also, it is possible to pass an array to the WHERE clause, as in the example
1603+ below:
1604+
1605+ .. code-block :: php
1606+
1607+ $where = [
1608+ ['id', '<', 100], // WHERE `id` < 100
1609+ ['author', 'is not null'], // AND `author` IS NOT NULL
1610+ ];
1611+ $data = $model->paginate($page, $perPage, $where); // array
1612+
1613+ The following SQL will be appended to the query:
1614+
1615+ .. code-block :: sql
1616+
1617+ WHERE `id` < 100
1618+ AND `author` IS NOT NULL
1619+
1620+ Also, it is possible to order the results by the last parameters:
1621+
1622+ .. code-block :: php
1623+
1624+ $orderBy = 'title'; // Column name
1625+ $orderByDirection = 'asc'; // asc or desc
1626+ $data = $model->paginate(
1627+ $page,
1628+ $perPage,
1629+ $where,
1630+ $orderBy,
1631+ $orderByDirection
1632+ ); // array
1633+
16021634 After calling the ``paginate `` method, the ``$pager `` property will have an
16031635instance of the **Framework\P agination\P ager ** class, which can be obtained by
16041636the ``getPager `` method.
0 commit comments