Skip to content

Commit a586e4d

Browse files
committed
Remove query input from $set in *Batch() methods
1 parent 91c1a20 commit a586e4d

2 files changed

Lines changed: 7 additions & 15 deletions

File tree

system/Database/BaseBuilder.php

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1917,16 +1917,14 @@ public function upsert($set = null, ?bool $escape = null)
19171917
/**
19181918
* Compiles batch upsert strings and runs the queries
19191919
*
1920-
* @param array|BaseBuilder|object|RawSql|null $set a dataset
1920+
* @param array|object|null $set a dataset
19211921
*
19221922
* @return false|int|string[] Number of affected rows or FALSE on failure, SQL array when testMode
19231923
*
19241924
* @throws DatabaseException
19251925
*/
19261926
public function upsertBatch($set = null, ?bool $escape = null, int $batchSize = 100)
19271927
{
1928-
$this->setQueryAsData($set);
1929-
19301928
if (isset($this->QBOptions['setQueryAsData'])) {
19311929
$sql = $this->_upsertBatch($this->QBFrom[0], $this->QBKeys, []);
19321930

@@ -2151,14 +2149,12 @@ protected function formatValues(array $values): array
21512149
/**
21522150
* Compiles batch insert strings and runs the queries
21532151
*
2154-
* @param array|BaseBuilder|object|RawSql|null $set a dataset
2152+
* @param array|object|null $set a dataset
21552153
*
21562154
* @return false|int|string[] Number of rows inserted or FALSE on failure, SQL array when testMode
21572155
*/
21582156
public function insertBatch($set = null, ?bool $escape = null, int $batchSize = 100)
21592157
{
2160-
$this->setQueryAsData($set);
2161-
21622158
if (isset($this->QBOptions['setQueryAsData'])) {
21632159
$sql = $this->_insertBatch($this->QBFrom[0], $this->QBKeys, []);
21642160

@@ -2520,15 +2516,13 @@ protected function validateUpdate(): bool
25202516
/**
25212517
* Sets data and calls batchExecute to run queries
25222518
*
2523-
* @param array|BaseBuilder|object|RawSql|null $set a dataset or select query
2524-
* @param array|RawSql|string|null $constraints
2519+
* @param array|object|null $set a dataset
2520+
* @param array|RawSql|string|null $constraints
25252521
*
25262522
* @return false|int|string[] Number of rows affected or FALSE on failure, SQL array when testMode
25272523
*/
25282524
public function updateBatch($set = null, $constraints = null, int $batchSize = 100)
25292525
{
2530-
$this->setQueryAsData($set);
2531-
25322526
$this->onConstraint($constraints);
25332527

25342528
if (isset($this->QBOptions['setQueryAsData'])) {
@@ -2786,15 +2780,13 @@ public function delete($where = '', ?int $limit = null, bool $resetData = true)
27862780
/**
27872781
* Sets data and calls batchExecute to run queries
27882782
*
2789-
* @param array|BaseBuilder|object|RawSql|null $set a dataset
2790-
* @param array|RawSql|null $constraints
2783+
* @param array|object|null $set a dataset
2784+
* @param array|RawSql|null $constraints
27912785
*
27922786
* @return false|int|string[] Number of rows affected or FALSE on failure, SQL array when testMode
27932787
*/
27942788
public function deleteBatch($set = null, $constraints = null, int $batchSize = 100)
27952789
{
2796-
$this->setQueryAsData($set);
2797-
27982790
$this->onConstraint($constraints);
27992791

28002792
if (isset($this->QBOptions['setQueryAsData'])) {

user_guide_src/source/database/query_builder/115.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
$additionalUpdateField = ['updated_at' => new RawSql('CURRENT_TIMESTAMP')];
99

10-
$sql = $builder->onConstraint('email')->updateFields($additionalUpdateField, true)->upsertBatch($query);
10+
$sql = $builder->setQueryAsData($query)->onConstraint('email')->updateFields($additionalUpdateField, true)->upsertBatch();
1111
/* MySQLi produces:
1212
INSERT INTO `db_user` (`country`, `email`, `name`)
1313
SELECT user2.name, user2.email, user2.country

0 commit comments

Comments
 (0)