File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -2054,13 +2054,15 @@ public function onConstraint($set)
2054
2054
/**
2055
2055
* Sets data source as a query for insert/update/upsert
2056
2056
*
2057
- * @param BaseBuilder|string $query
2057
+ * @param BaseBuilder|RawSql| string $query
2058
2058
*/
2059
2059
public function fromQuery ($ query ): BaseBuilder
2060
2060
{
2061
2061
if (! empty ($ query )) {
2062
2062
if ($ query instanceof BaseBuilder) {
2063
2063
$ query = $ query ->getCompiledSelect ();
2064
+ } elseif ($ query instanceof RawSql) {
2065
+ $ query = $ query ->__toString ();
2064
2066
}
2065
2067
2066
2068
if (is_string ($ query )) {
@@ -2472,8 +2474,24 @@ protected function validateUpdate(): bool
2472
2474
*/
2473
2475
public function updateBatch ($ set = null , $ constraints = null , int $ batchSize = 100 )
2474
2476
{
2477
+ $ this ->fromQuery ($ set );
2478
+
2475
2479
$ this ->onConstraint ($ constraints );
2476
2480
2481
+ if (isset ($ this ->QBOptions ['fromQuery ' ])) {
2482
+ $ sql = $ this ->_updateBatch ($ this ->QBFrom [0 ], $ this ->QBKeys , []);
2483
+
2484
+ if ($ sql === '' ) {
2485
+ return false ; // @codeCoverageIgnore
2486
+ }
2487
+
2488
+ $ this ->db ->query ($ sql , null , false );
2489
+
2490
+ $ this ->resetWrite ();
2491
+
2492
+ return $ this ->testMode ? $ sql : $ this ->db ->affectedRows ();
2493
+ }
2494
+
2477
2495
if ($ set !== null && $ set !== []) {
2478
2496
$ this ->setData ($ set , true );
2479
2497
}
You can’t perform that action at this time.
0 commit comments