@@ -39,13 +39,46 @@ The first element is the results from the database, **users**, which is retrieve
3939the Model will hold on to the instance it used and store it in the public property, ``$pager ``. So, we grab
4040that and assign it to the ``$pager `` variable in the view.
4141
42- .. important :: It is important to understand that the ``Model::paginate()`` method uses the **Model** and **QueryBuilder** methods.
43- Therefore, trying to use ``$db->query() `` and ``Model::paginate() `` **will not work ** because ``$db->query() `` executes
44- the query immediately and is not associated with a QueryBuilder.
42+ Customizing Query for Pagination
43+ ================================
4544
46- To define conditions for pagination in a model, you can:
45+ To customize a query for pagination in a model, you can add
46+ :doc: `Query Builder <../database/query_builder >` methods before ``paginate() ``
47+ method.
48+
49+ Adding WHERE
50+ ------------
51+
52+ If you want to add WHERE conditions, you can specify conditions directly:
4753
4854.. literalinclude :: pagination/003.php
55+ :lines: 2-
56+
57+ You can move the conditions to a separate method:
58+
59+ .. literalinclude :: pagination/017.php
60+
61+ .. literalinclude :: pagination/018.php
62+ :lines: 2-
63+
64+ Adding JOIN
65+ -----------
66+
67+ You can join another table:
68+
69+ .. literalinclude :: pagination/016.php
70+
71+ .. important :: It is important to understand that the ``Model::paginate()`` method
72+ uses the **Model ** and the **Query Builder ** instance in the Model.
73+ Therefore, trying to use ``Model::paginate() `` with :ref: `db-query `
74+ **will not work ** because ``$db->query() `` executes the query immediately
75+ and is not associated with the Query Builder.
76+
77+ If you need a complicated SQL query that you cannot write with Query Builder,
78+ try using :ref: `db-query ` and `Manual Pagination `_.
79+
80+ Displaying Pager Links
81+ ======================
4982
5083Within the view, we then need to tell it where to display the resulting links::
5184
0 commit comments