Skip to content

Commit

Permalink
docs: add sub section titles and tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Jan 20, 2024
1 parent 4e29a3a commit ac289ed
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions user_guide_src/source/database/query_builder.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1107,18 +1107,20 @@ $builder->updateBatch()
.. note:: Since v4.3.0, the second parameter ``$index`` of ``updateBatch()`` has
changed to ``$constraints``. It now accepts types array, string, or ``RawSql``.

Update from Data
^^^^^^^^^^^^^^^^

Generates an update string based on the data you supply, and runs the query.
You can either pass an **array** or an **object** to the method.
Here is an example using an array:

.. literalinclude:: query_builder/092.php

.. note:: Since v4.3.0, the generated SQL structure has been Improved.
The first parameter is an associative array of values, the second parameter is the where keys.

The first parameter is an associative array of values, the second parameter is the where key.
.. note:: Since v4.3.0, the generated SQL structure has been Improved.

Since v4.3.0, you can also use the ``setQueryAsData()``, ``onConstraint()``, and
``updateFields()`` methods:
Since v4.3.0, you can also use the ``onConstraint()`` and ``updateFields()`` methods:

.. literalinclude:: query_builder/120.php

Expand All @@ -1130,12 +1132,12 @@ Since v4.3.0, you can also use the ``setQueryAsData()``, ``onConstraint()``, and
due to the very nature of how it works. Instead, ``updateBatch()``
returns the number of rows affected.

You can also update from a query:
Update from a Query
^^^^^^^^^^^^^^^^^^^

.. literalinclude:: query_builder/116.php
Since v4.3.0, you can also update from a query with the ``setQueryAsData()`` method:

.. note:: The ``setQueryAsData()``, ``onConstraint()``, and ``updateFields()``
methods can be used since v4.3.0.
.. literalinclude:: query_builder/116.php

.. note:: It is required to alias the columns of the select query to match those of the target table.

Expand Down

0 comments on commit ac289ed

Please sign in to comment.