@@ -878,6 +878,9 @@ insertBatch
878
878
$builder->insertBatch()
879
879
-----------------------
880
880
881
+ Insert from Data
882
+ ^^^^^^^^^^^^^^^^
883
+
881
884
Generates an insert string based on the data you supply, and runs the
882
885
query. You can either pass an **array ** or an **object ** to the
883
886
method. Here is an example using an array:
@@ -890,6 +893,9 @@ The first parameter is an associative array of values.
890
893
891
894
.. warning :: When you use ``RawSql``, you MUST escape the data manually. Failure to do so could result in SQL injections.
892
895
896
+ Insert from a Query
897
+ ^^^^^^^^^^^^^^^^^^^
898
+
893
899
You can also insert from a query:
894
900
895
901
.. literalinclude :: query_builder/117.php
@@ -954,18 +960,26 @@ $builder->upsertBatch()
954
960
955
961
.. versionadded :: 4.3.0
956
962
963
+ Upsert from Data
964
+ ^^^^^^^^^^^^^^^^
965
+
957
966
Generates an upsert string based on the data you supply, and runs the
958
967
query. You can either pass an **array ** or an **object ** to the
959
968
method. By default a constraint will be defined in order. A primary
960
969
key will be selected first and then unique keys. MySQL will use any
961
- constraint by default. Here is an example using an array:
970
+ constraint by default.
971
+
972
+ Here is an example using an array:
962
973
963
974
.. literalinclude :: query_builder/108.php
964
975
965
976
The first parameter is an associative array of values.
966
977
967
978
.. note :: All values are escaped automatically producing safer queries.
968
979
980
+ Upsert from a Query
981
+ ^^^^^^^^^^^^^^^^^^^
982
+
969
983
You can also upsert from a query:
970
984
971
985
.. literalinclude :: query_builder/115.php
@@ -1096,6 +1110,16 @@ Or as an array:
1096
1110
You may also use the ``$builder->set() `` method described above when
1097
1111
performing updates.
1098
1112
1113
+ $builder->getCompiledUpdate()
1114
+ -----------------------------
1115
+
1116
+ This works exactly the same way as ``$builder->getCompiledInsert() `` except
1117
+ that it produces an **UPDATE ** SQL string instead of an **INSERT ** SQL string.
1118
+
1119
+ For more information view documentation for `$builder->getCompiledInsert() `_.
1120
+
1121
+ .. note :: This method doesn't work for batched updates.
1122
+
1099
1123
.. _update-batch :
1100
1124
1101
1125
UpdateBatch
@@ -1141,16 +1165,6 @@ Since v4.3.0, you can also update from a query with the ``setQueryAsData()`` met
1141
1165
1142
1166
.. note :: It is required to alias the columns of the select query to match those of the target table.
1143
1167
1144
- $builder->getCompiledUpdate()
1145
- -----------------------------
1146
-
1147
- This works exactly the same way as ``$builder->getCompiledInsert() `` except
1148
- that it produces an **UPDATE ** SQL string instead of an **INSERT ** SQL string.
1149
-
1150
- For more information view documentation for ``$builder->getCompiledInsert() ``.
1151
-
1152
- .. note :: This method doesn't work for batched updates.
1153
-
1154
1168
*************
1155
1169
Deleting Data
1156
1170
*************
@@ -1174,27 +1188,42 @@ the data to the first parameter of the method:
1174
1188
If you want to delete all data from a table, you can use the ``truncate() ``
1175
1189
method, or ``emptyTable() ``.
1176
1190
1191
+ $builder->getCompiledDelete()
1192
+ -----------------------------
1193
+
1194
+ This works exactly the same way as ``$builder->getCompiledInsert() `` except
1195
+ that it produces a **DELETE ** SQL string instead of an **INSERT ** SQL string.
1196
+
1197
+ For more information view documentation for `$builder->getCompiledInsert() `_.
1198
+
1177
1199
.. _delete-batch :
1178
1200
1201
+ DeleteBatch
1202
+ ===========
1203
+
1179
1204
$builder->deleteBatch()
1180
1205
-----------------------
1181
1206
1182
1207
.. versionadded :: 4.3.0
1183
1208
1209
+ Delete from Data
1210
+ ^^^^^^^^^^^^^^^^
1211
+
1184
1212
Generates a batch **DELETE ** statement based on a set of data.
1185
1213
1186
1214
.. literalinclude :: query_builder/118.php
1187
1215
1188
1216
This method may be especially useful when deleting data in a table with a composite primary key.
1189
1217
1190
- .. note :: SQLite does not support the use of ``where()``.
1218
+ .. note :: SQLite3 does not support the use of ``where()``.
1219
+
1220
+ Delete from a Query
1221
+ ^^^^^^^^^^^^^^^^^^^
1191
1222
1192
1223
You can also delete from a query:
1193
1224
1194
1225
.. literalinclude :: query_builder/119.php
1195
1226
1196
- .. note :: ``$deleteBatch()`` can be used since v4.3.0.
1197
-
1198
1227
$builder->emptyTable()
1199
1228
----------------------
1200
1229
@@ -1213,14 +1242,6 @@ Generates a **TRUNCATE** SQL string and runs the query.
1213
1242
.. note :: If the TRUNCATE command isn't available, ``truncate()`` will
1214
1243
execute as "DELETE FROM table".
1215
1244
1216
- $builder->getCompiledDelete()
1217
- -----------------------------
1218
-
1219
- This works exactly the same way as ``$builder->getCompiledInsert() `` except
1220
- that it produces a **DELETE ** SQL string instead of an **INSERT ** SQL string.
1221
-
1222
- For more information view documentation for ``$builder->getCompiledInsert() ``.
1223
-
1224
1245
**********************
1225
1246
Conditional Statements
1226
1247
**********************
0 commit comments