Skip to content

Commit 70d25ed

Browse files
committed
Rename setQuery() to setQueryAsData()
1 parent e1855f6 commit 70d25ed

10 files changed

Lines changed: 41 additions & 41 deletions

File tree

system/Database/BaseBuilder.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ class BaseBuilder
169169
* tableIdentity?: string,
170170
* updateFields?: array,
171171
* constraints?: array,
172-
* setQuery?: string,
172+
* setQueryAsData?: string,
173173
* sql?: string,
174174
* alias?: string
175175
* }
@@ -1925,9 +1925,9 @@ public function upsert($set = null, ?bool $escape = null)
19251925
*/
19261926
public function upsertBatch($set = null, ?bool $escape = null, int $batchSize = 100)
19271927
{
1928-
$this->setQuery($set);
1928+
$this->setQueryAsData($set);
19291929

1930-
if (isset($this->QBOptions['setQuery'])) {
1930+
if (isset($this->QBOptions['setQueryAsData'])) {
19311931
$sql = $this->_upsertBatch($this->QBFrom[0], $this->QBKeys, []);
19321932

19331933
if ($sql === '') {
@@ -1983,8 +1983,8 @@ protected function _upsertBatch(string $table, array $keys, array $values): stri
19831983
$this->QBOptions['sql'] = $sql;
19841984
}
19851985

1986-
if (isset($this->QBOptions['setQuery'])) {
1987-
$data = $this->QBOptions['setQuery'];
1986+
if (isset($this->QBOptions['setQueryAsData'])) {
1987+
$data = $this->QBOptions['setQueryAsData'];
19881988
} else {
19891989
$data = 'VALUES ' . implode(', ', $this->formatValues($values)) . "\n";
19901990
}
@@ -2092,7 +2092,7 @@ public function onConstraint($set)
20922092
* @param string $alias
20932093
* @param array|string|null $columns an array or comma delimited string of columns
20942094
*/
2095-
public function setQuery($query, $alias = null, $columns = null): BaseBuilder
2095+
public function setQueryAsData($query, $alias = null, $columns = null): BaseBuilder
20962096
{
20972097
if (is_string($query)) {
20982098
throw new InvalidArgumentException('$query parameter must be BaseBuilder or RawSql class.');
@@ -2124,7 +2124,7 @@ public function setQuery($query, $alias = null, $columns = null): BaseBuilder
21242124
$columns[$key] = $this->db->escapeChar . $value . $this->db->escapeChar;
21252125
}
21262126

2127-
$this->QBOptions['setQuery'] = $query;
2127+
$this->QBOptions['setQueryAsData'] = $query;
21282128
$this->QBKeys = $columns;
21292129
$this->QBSet = [];
21302130
}
@@ -2157,9 +2157,9 @@ protected function formatValues(array $values): array
21572157
*/
21582158
public function insertBatch($set = null, ?bool $escape = null, int $batchSize = 100)
21592159
{
2160-
$this->setQuery($set);
2160+
$this->setQueryAsData($set);
21612161

2162-
if (isset($this->QBOptions['setQuery'])) {
2162+
if (isset($this->QBOptions['setQueryAsData'])) {
21632163
$sql = $this->_insertBatch($this->QBFrom[0], $this->QBKeys, []);
21642164

21652165
if ($sql === '') {
@@ -2205,8 +2205,8 @@ protected function _insertBatch(string $table, array $keys, array $values): stri
22052205
$this->QBOptions['sql'] = $sql;
22062206
}
22072207

2208-
if (isset($this->QBOptions['setQuery'])) {
2209-
$data = $this->QBOptions['setQuery'];
2208+
if (isset($this->QBOptions['setQueryAsData'])) {
2209+
$data = $this->QBOptions['setQueryAsData'];
22102210
} else {
22112211
$data = 'VALUES ' . implode(', ', $this->formatValues($values));
22122212
}
@@ -2527,11 +2527,11 @@ protected function validateUpdate(): bool
25272527
*/
25282528
public function updateBatch($set = null, $constraints = null, int $batchSize = 100)
25292529
{
2530-
$this->setQuery($set);
2530+
$this->setQueryAsData($set);
25312531

25322532
$this->onConstraint($constraints);
25332533

2534-
if (isset($this->QBOptions['setQuery'])) {
2534+
if (isset($this->QBOptions['setQueryAsData'])) {
25352535
$sql = $this->_updateBatch($this->QBFrom[0], $this->QBKeys, []);
25362536

25372537
if ($sql === '') {
@@ -2630,8 +2630,8 @@ protected function _updateBatch(string $table, array $keys, array $values): stri
26302630
$this->QBOptions['sql'] = $sql;
26312631
}
26322632

2633-
if (isset($this->QBOptions['setQuery'])) {
2634-
$data = $this->QBOptions['setQuery'];
2633+
if (isset($this->QBOptions['setQueryAsData'])) {
2634+
$data = $this->QBOptions['setQueryAsData'];
26352635
} else {
26362636
$data = implode(
26372637
" UNION ALL\n",
@@ -3265,7 +3265,7 @@ protected function isLiteral(string $str): bool
32653265
*
32663266
* @return $this
32673267
*/
3268-
public function resetQuery()
3268+
public function resetQueryAsData()
32693269
{
32703270
$this->resetSelect();
32713271
$this->resetWrite();
@@ -3420,7 +3420,7 @@ protected function setBind(string $key, $value = null, bool $escape = true): str
34203420
*/
34213421
protected function cleanClone()
34223422
{
3423-
return (clone $this)->from([], true)->resetQuery();
3423+
return (clone $this)->from([], true)->resetQueryAsData();
34243424
}
34253425

34263426
/**

system/Database/MySQLi/Builder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ protected function _updateBatch(string $table, array $keys, array $values): stri
124124
$this->QBOptions['sql'] = $sql;
125125
}
126126

127-
if (isset($this->QBOptions['setQuery'])) {
128-
$data = $this->QBOptions['setQuery'];
127+
if (isset($this->QBOptions['setQueryAsData'])) {
128+
$data = $this->QBOptions['setQueryAsData'];
129129
} else {
130130
$data = implode(
131131
" UNION ALL\n",

system/Database/OCI8/Builder.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ protected function _insertBatch(string $table, array $keys, array $values): stri
8181
$this->QBOptions['sql'] = $sql;
8282
}
8383

84-
if (isset($this->QBOptions['setQuery'])) {
85-
$data = $this->QBOptions['setQuery'];
84+
if (isset($this->QBOptions['setQueryAsData'])) {
85+
$data = $this->QBOptions['setQueryAsData'];
8686
} else {
8787
$data = implode(
8888
" FROM DUAL UNION ALL\n",
@@ -307,8 +307,8 @@ protected function _updateBatch(string $table, array $keys, array $values): stri
307307
$this->QBOptions['sql'] = $sql;
308308
}
309309

310-
if (isset($this->QBOptions['setQuery'])) {
311-
$data = $this->QBOptions['setQuery'];
310+
if (isset($this->QBOptions['setQueryAsData'])) {
311+
$data = $this->QBOptions['setQueryAsData'];
312312
} else {
313313
$data = implode(
314314
" UNION ALL\n",
@@ -416,8 +416,8 @@ protected function _upsertBatch(string $table, array $keys, array $values): stri
416416
$this->QBOptions['sql'] = $sql;
417417
}
418418

419-
if (isset($this->QBOptions['setQuery'])) {
420-
$data = $this->QBOptions['setQuery'];
419+
if (isset($this->QBOptions['setQueryAsData'])) {
420+
$data = $this->QBOptions['setQueryAsData'];
421421
} else {
422422
$data = implode(
423423
" FROM DUAL UNION ALL\n",

system/Database/Postgre/Builder.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,8 @@ protected function _insertBatch(string $table, array $keys, array $values): stri
209209
$this->QBOptions['sql'] = $sql;
210210
}
211211

212-
if (isset($this->QBOptions['setQuery'])) {
213-
$data = $this->QBOptions['setQuery'];
212+
if (isset($this->QBOptions['setQueryAsData'])) {
213+
$data = $this->QBOptions['setQueryAsData'];
214214
} else {
215215
$data = 'VALUES ' . implode(', ', $this->formatValues($values));
216216
}
@@ -400,8 +400,8 @@ protected function _upsertBatch(string $table, array $keys, array $values): stri
400400
$this->QBOptions['sql'] = $sql;
401401
}
402402

403-
if (isset($this->QBOptions['setQuery'])) {
404-
$data = $this->QBOptions['setQuery'];
403+
if (isset($this->QBOptions['setQueryAsData'])) {
404+
$data = $this->QBOptions['setQueryAsData'];
405405
} else {
406406
$data = 'VALUES ' . implode(', ', $this->formatValues($values)) . "\n";
407407
}

system/Database/SQLSRV/Builder.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,8 @@ protected function _insertBatch(string $table, array $keys, array $values): stri
190190
$this->QBOptions['sql'] = $sql;
191191
}
192192

193-
if (isset($this->QBOptions['setQuery'])) {
194-
$data = $this->QBOptions['setQuery'];
193+
if (isset($this->QBOptions['setQueryAsData'])) {
194+
$data = $this->QBOptions['setQueryAsData'];
195195
} else {
196196
$data = 'VALUES ' . implode(', ', $this->formatValues($values));
197197
}
@@ -756,8 +756,8 @@ protected function _upsertBatch(string $table, array $keys, array $values): stri
756756
$this->QBOptions['sql'] = $sql;
757757
}
758758

759-
if (isset($this->QBOptions['setQuery'])) {
760-
$data = $this->QBOptions['setQuery'];
759+
if (isset($this->QBOptions['setQueryAsData'])) {
760+
$data = $this->QBOptions['setQueryAsData'];
761761
} else {
762762
$data = 'VALUES ' . implode(', ', $this->formatValues($values)) . "\n";
763763
}

system/Database/SQLite3/Builder.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ protected function _updateBatch(string $table, array $keys, array $values): stri
9393
return ''; // @codeCoverageIgnore
9494
}
9595

96-
if (count($constraints) > 1 || isset($this->QBOptions['setQuery']) || (current($constraints) instanceof RawSql)) {
96+
if (count($constraints) > 1 || isset($this->QBOptions['setQueryAsData']) || (current($constraints) instanceof RawSql)) {
9797
throw new DatabaseException('You are trying to use a feature which requires SQLite version 3.33 or higher.');
9898
}
9999

@@ -201,10 +201,10 @@ protected function _upsertBatch(string $table, array $keys, array $values): stri
201201
$this->QBOptions['sql'] = $sql;
202202
}
203203

204-
if (isset($this->QBOptions['setQuery'])) {
205-
$hasWhere = stripos($this->QBOptions['setQuery'], 'WHERE') > 0;
204+
if (isset($this->QBOptions['setQueryAsData'])) {
205+
$hasWhere = stripos($this->QBOptions['setQueryAsData'], 'WHERE') > 0;
206206

207-
$data = $this->QBOptions['setQuery'] . ($hasWhere ? '' : "\nWHERE 1 = 1\n");
207+
$data = $this->QBOptions['setQueryAsData'] . ($hasWhere ? '' : "\nWHERE 1 = 1\n");
208208
} else {
209209
$data = 'VALUES ' . implode(', ', $this->formatValues($values)) . "\n";
210210
}

tests/system/Database/Live/InsertTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ public function testInsertBatchWithQueryAndRawSqlAndManualColumns()
239239
->getCompiledSelect();
240240

241241
$this->db->table('user')
242-
->setQuery(new RawSql($sql), null, 'name, email, country')
242+
->setQueryAsData(new RawSql($sql), null, 'name, email, country')
243243
->insertBatch();
244244

245245
$this->seeInDatabase('user', ['name' => 'New User user2']);

user_guide_src/source/database/query_builder.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1393,7 +1393,7 @@ Class Reference
13931393

13941394
Specifies the ``FROM`` clause of a query using a subquery.
13951395

1396-
.. php:method:: setQuery($query[, $alias[, $columns = null]])
1396+
.. php:method:: setQueryAsData($query[, $alias[, $columns = null]])
13971397
13981398
:param BaseBuilder|RawSql $query: Instance of the BaseBuilder or RawSql
13991399
:param array|string|null $columns: Array or comma delimited string of columns in the query

user_guide_src/source/database/query_builder/116.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
$additionalUpdateField = ['updated_at' => new RawSql('CURRENT_TIMESTAMP')];
99

1010
$sql = $builder->table('user')
11-
->setData($query, null, 'u')
11+
->setQueryAsData($query, null, 'u')
1212
->onConstraint('email')
1313
->updateFields($additionalUpdateField, true)
1414
->updateBatch();

user_guide_src/source/database/query_builder/117.php

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

1010
$sql = $builder
1111
->ignore(true)
12-
->setQuery(new RawSql($query), null, 'name, country, email')
12+
->setQueryAsData(new RawSql($query), null, 'name, country, email')
1313
->insertBatch();
1414
/* MySQLi produces:
1515
INSERT IGNORE INTO `db_user` (`name`, `country`, `email`)

0 commit comments

Comments
 (0)