Skip to content

Commit 4307472

Browse files
committed
docs: add docs
1 parent 2f9a36c commit 4307472

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

user_guide_src/source/changelogs/v4.5.0.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,20 @@ Database
239239
Query Builder
240240
-------------
241241

242+
.. _v450-query-builder-limit-0-behavior:
243+
244+
limit(0) Behavior
245+
^^^^^^^^^^^^^^^^^
246+
247+
- Added a feature flag ``Feature::$limitZeroAsAll`` to fix the incorrect behavior
248+
of ``limit(0)``.
249+
- If ``LIMIT 0`` is specified in a SQL statement, 0 records are returned. However,
250+
there is a bug in the Query Builder, and if ``limit(0)`` is specified, the
251+
generated SQL statement will have no ``LIMIT`` clause and all records will be
252+
returned.
253+
- It is recommended that ``$limitZeroAsAll`` in **app/Config/Feature.php** be set
254+
to ``false`` as this incorrect behavior will be fixed in a future version.
255+
242256
Forge
243257
-----
244258

user_guide_src/source/database/query_builder.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,14 @@ Lets you limit the number of rows you would like returned by the query:
681681

682682
.. literalinclude:: query_builder/070.php
683683

684+
.. note:: If ``LIMIT 0`` is specified in a SQL statement, 0 records are returned.
685+
However, there is a bug in the Query Builder, and if ``limit(0)`` is specified,
686+
the generated SQL statement will have no ``LIMIT`` clause and all records will
687+
be returned. To fix the incorrect behavior, a setting was added in v4.5.0. See
688+
:ref:`v450-query-builder-limit-0-behavior` for details. The incorrect behavior
689+
will be fixed in a future version, so it is recommended that you change the
690+
default setting.
691+
684692
The second parameter lets you set a result offset.
685693

686694
.. literalinclude:: query_builder/071.php

user_guide_src/source/installation/upgrade_450.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,8 @@ Others
260260
- The default value of ``DBCollat`` in ``$default`` has been change to ``utf8mb4_general_ci``.
261261
- The default value of ``DBCollat`` in ``$tests`` has been change to ``''``.
262262
- app/Config/Feature.php
263+
- ``Config\Feature::$limitZeroAsAll`` has been added. See
264+
:ref:`v450-query-builder-limit-0-behavior`.
263265
- ``Config\Feature::$multipleFilters`` has been removed, because now
264266
:ref:`multiple-filters` are always enabled.
265267
- app/Config/Kint.php

user_guide_src/source/installation/upgrade_database.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Upgrade Guide
4343
- ``$this->db->having('user_id', 45);`` to ``$builder->having('user_id', 45);``
4444
6. CI4 does not provide `Database Caching <https://www.codeigniter.com/userguide3/database/caching.html>`_
4545
layer known from CI3, so if you need to cache the result, use :doc:`../libraries/caching` instead.
46+
7. If you use ``limit(0)`` in Query Builder, CI4 returns all records in stead of no records due to a bug. But since v4.5.0, you can change the incorrect behavior with a setting. So change the setting. See :ref:`v450-query-builder-limit-0-behavior` for details.
4647

4748
Code Example
4849
============

0 commit comments

Comments
 (0)