Skip to content

Commit

Permalink
docs: add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Dec 3, 2023
1 parent 2f9a36c commit 4307472
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
14 changes: 14 additions & 0 deletions user_guide_src/source/changelogs/v4.5.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,20 @@ Database
Query Builder
-------------

.. _v450-query-builder-limit-0-behavior:

limit(0) Behavior
^^^^^^^^^^^^^^^^^

- Added a feature flag ``Feature::$limitZeroAsAll`` to fix the incorrect behavior
of ``limit(0)``.
- If ``LIMIT 0`` is specified in a SQL statement, 0 records are returned. However,
there is a bug in the Query Builder, and if ``limit(0)`` is specified, the
generated SQL statement will have no ``LIMIT`` clause and all records will be
returned.
- It is recommended that ``$limitZeroAsAll`` in **app/Config/Feature.php** be set
to ``false`` as this incorrect behavior will be fixed in a future version.

Forge
-----

Expand Down
8 changes: 8 additions & 0 deletions user_guide_src/source/database/query_builder.rst
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,14 @@ Lets you limit the number of rows you would like returned by the query:

.. literalinclude:: query_builder/070.php

.. note:: If ``LIMIT 0`` is specified in a SQL statement, 0 records are returned.
However, there is a bug in the Query Builder, and if ``limit(0)`` is specified,
the generated SQL statement will have no ``LIMIT`` clause and all records will
be returned. To fix the incorrect behavior, a setting was added in v4.5.0. See
:ref:`v450-query-builder-limit-0-behavior` for details. The incorrect behavior
will be fixed in a future version, so it is recommended that you change the
default setting.

The second parameter lets you set a result offset.

.. literalinclude:: query_builder/071.php
Expand Down
2 changes: 2 additions & 0 deletions user_guide_src/source/installation/upgrade_450.rst
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ Others
- The default value of ``DBCollat`` in ``$default`` has been change to ``utf8mb4_general_ci``.
- The default value of ``DBCollat`` in ``$tests`` has been change to ``''``.
- app/Config/Feature.php
- ``Config\Feature::$limitZeroAsAll`` has been added. See
:ref:`v450-query-builder-limit-0-behavior`.
- ``Config\Feature::$multipleFilters`` has been removed, because now
:ref:`multiple-filters` are always enabled.
- app/Config/Kint.php
Expand Down
1 change: 1 addition & 0 deletions user_guide_src/source/installation/upgrade_database.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Upgrade Guide
- ``$this->db->having('user_id', 45);`` to ``$builder->having('user_id', 45);``
6. CI4 does not provide `Database Caching <https://www.codeigniter.com/userguide3/database/caching.html>`_
layer known from CI3, so if you need to cache the result, use :doc:`../libraries/caching` instead.
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.

Code Example
============
Expand Down

0 comments on commit 4307472

Please sign in to comment.