From ac289ed9ded14b17dadde4387ce17c599825501c Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 18 Jan 2024 10:49:18 +0900 Subject: [PATCH] docs: add sub section titles and tweaks --- .../source/database/query_builder.rst | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/user_guide_src/source/database/query_builder.rst b/user_guide_src/source/database/query_builder.rst index 0be07d71340b..5e6d54985a6c 100755 --- a/user_guide_src/source/database/query_builder.rst +++ b/user_guide_src/source/database/query_builder.rst @@ -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 @@ -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.