From 6d3ac2dd4ccfb670adc0610dcb182515b307d829 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 25 Jan 2024 10:16:28 +0900 Subject: [PATCH 1/6] docs: add section titles for DeteteBatch --- user_guide_src/source/database/query_builder.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/user_guide_src/source/database/query_builder.rst b/user_guide_src/source/database/query_builder.rst index 5e6d54985a6c..0849f1d4bb27 100755 --- a/user_guide_src/source/database/query_builder.rst +++ b/user_guide_src/source/database/query_builder.rst @@ -1176,11 +1176,17 @@ method, or ``emptyTable()``. .. _delete-batch: +DeleteBatch +=========== + $builder->deleteBatch() ----------------------- .. versionadded:: 4.3.0 +Delete from Data +^^^^^^^^^^^^^^^^ + Generates a batch **DELETE** statement based on a set of data. .. literalinclude:: query_builder/118.php @@ -1189,6 +1195,9 @@ This method may be especially useful when deleting data in a table with a compos .. note:: SQLite does not support the use of ``where()``. +Delete from a Query +^^^^^^^^^^^^^^^^^^^ + You can also delete from a query: .. literalinclude:: query_builder/119.php From 3c3668623640dff621113d6854e4857c722457ae Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 25 Jan 2024 10:17:09 +0900 Subject: [PATCH 2/6] docs: remove unneeded note --- user_guide_src/source/database/query_builder.rst | 2 -- 1 file changed, 2 deletions(-) diff --git a/user_guide_src/source/database/query_builder.rst b/user_guide_src/source/database/query_builder.rst index 0849f1d4bb27..8d4643c3dff9 100755 --- a/user_guide_src/source/database/query_builder.rst +++ b/user_guide_src/source/database/query_builder.rst @@ -1202,8 +1202,6 @@ You can also delete from a query: .. literalinclude:: query_builder/119.php -.. note:: ``$deleteBatch()`` can be used since v4.3.0. - $builder->emptyTable() ---------------------- From 4531b3bb3e419aee923ea0d8bf84c6ed62c17202 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 25 Jan 2024 10:19:12 +0900 Subject: [PATCH 3/6] docs: move section positions --- .../source/database/query_builder.rst | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/user_guide_src/source/database/query_builder.rst b/user_guide_src/source/database/query_builder.rst index 8d4643c3dff9..1cb718b9338e 100755 --- a/user_guide_src/source/database/query_builder.rst +++ b/user_guide_src/source/database/query_builder.rst @@ -1096,6 +1096,16 @@ Or as an array: You may also use the ``$builder->set()`` method described above when performing updates. +$builder->getCompiledUpdate() +----------------------------- + +This works exactly the same way as ``$builder->getCompiledInsert()`` except +that it produces an **UPDATE** SQL string instead of an **INSERT** SQL string. + +For more information view documentation for `$builder->getCompiledInsert()`_. + +.. note:: This method doesn't work for batched updates. + .. _update-batch: UpdateBatch @@ -1141,16 +1151,6 @@ Since v4.3.0, you can also update from a query with the ``setQueryAsData()`` met .. note:: It is required to alias the columns of the select query to match those of the target table. -$builder->getCompiledUpdate() ------------------------------ - -This works exactly the same way as ``$builder->getCompiledInsert()`` except -that it produces an **UPDATE** SQL string instead of an **INSERT** SQL string. - -For more information view documentation for ``$builder->getCompiledInsert()``. - -.. note:: This method doesn't work for batched updates. - ************* Deleting Data ************* @@ -1174,6 +1174,14 @@ the data to the first parameter of the method: If you want to delete all data from a table, you can use the ``truncate()`` method, or ``emptyTable()``. +$builder->getCompiledDelete() +----------------------------- + +This works exactly the same way as ``$builder->getCompiledInsert()`` except +that it produces a **DELETE** SQL string instead of an **INSERT** SQL string. + +For more information view documentation for `$builder->getCompiledInsert()`_. + .. _delete-batch: DeleteBatch @@ -1220,14 +1228,6 @@ Generates a **TRUNCATE** SQL string and runs the query. .. note:: If the TRUNCATE command isn't available, ``truncate()`` will execute as "DELETE FROM table". -$builder->getCompiledDelete() ------------------------------ - -This works exactly the same way as ``$builder->getCompiledInsert()`` except -that it produces a **DELETE** SQL string instead of an **INSERT** SQL string. - -For more information view documentation for ``$builder->getCompiledInsert()``. - ********************** Conditional Statements ********************** From 6df49112b8d37e911bf884408f776e89f59f77d3 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 25 Jan 2024 10:20:15 +0900 Subject: [PATCH 4/6] docs: replace SQLite with SQLite3 It is the DB driver name. --- user_guide_src/source/database/query_builder.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/database/query_builder.rst b/user_guide_src/source/database/query_builder.rst index 1cb718b9338e..6383f8b26909 100755 --- a/user_guide_src/source/database/query_builder.rst +++ b/user_guide_src/source/database/query_builder.rst @@ -1201,7 +1201,7 @@ Generates a batch **DELETE** statement based on a set of data. This method may be especially useful when deleting data in a table with a composite primary key. -.. note:: SQLite does not support the use of ``where()``. +.. note:: SQLite3 does not support the use of ``where()``. Delete from a Query ^^^^^^^^^^^^^^^^^^^ From 0a2f0c759cb5ada51b93d144096ea9a97babeab0 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 25 Jan 2024 12:24:57 +0900 Subject: [PATCH 5/6] docs: add section titles for UpsertBatch --- user_guide_src/source/database/query_builder.rst | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/user_guide_src/source/database/query_builder.rst b/user_guide_src/source/database/query_builder.rst index 6383f8b26909..658c177fc9d1 100755 --- a/user_guide_src/source/database/query_builder.rst +++ b/user_guide_src/source/database/query_builder.rst @@ -954,11 +954,16 @@ $builder->upsertBatch() .. versionadded:: 4.3.0 +Upsert from Data +^^^^^^^^^^^^^^^^ + Generates an upsert string based on the data you supply, and runs the query. You can either pass an **array** or an **object** to the method. By default a constraint will be defined in order. A primary key will be selected first and then unique keys. MySQL will use any -constraint by default. Here is an example using an array: +constraint by default. + +Here is an example using an array: .. literalinclude:: query_builder/108.php @@ -966,6 +971,9 @@ The first parameter is an associative array of values. .. note:: All values are escaped automatically producing safer queries. +Upsert from a Query +^^^^^^^^^^^^^^^^^^^ + You can also upsert from a query: .. literalinclude:: query_builder/115.php From ebb950abade7f5b965cdd7dace75b6cd42770e26 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 25 Jan 2024 12:27:44 +0900 Subject: [PATCH 6/6] docs: add section titles for InsertBatch --- user_guide_src/source/database/query_builder.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/user_guide_src/source/database/query_builder.rst b/user_guide_src/source/database/query_builder.rst index 658c177fc9d1..f0f9e90363ce 100755 --- a/user_guide_src/source/database/query_builder.rst +++ b/user_guide_src/source/database/query_builder.rst @@ -878,6 +878,9 @@ insertBatch $builder->insertBatch() ----------------------- +Insert from Data +^^^^^^^^^^^^^^^^ + Generates an insert 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: @@ -890,6 +893,9 @@ The first parameter is an associative array of values. .. warning:: When you use ``RawSql``, you MUST escape the data manually. Failure to do so could result in SQL injections. +Insert from a Query +^^^^^^^^^^^^^^^^^^^ + You can also insert from a query: .. literalinclude:: query_builder/117.php