@@ -170,6 +170,7 @@ class BaseBuilder
170
170
* sql?: string,
171
171
* alias?: string
172
172
* }
173
+ *
173
174
* @var array
174
175
*/
175
176
protected $ QBOptions ;
@@ -497,10 +498,10 @@ public function selectSubquery(BaseBuilder $subquery, string $as): self
497
498
* @used-by selectAvg()
498
499
* @used-by selectSum()
499
500
*
500
- * @return $this
501
- *
502
501
* @throws DatabaseException
503
502
* @throws DataException
503
+ *
504
+ * @return $this
504
505
*/
505
506
protected function maxMinAvgSum (string $ select = '' , string $ alias = '' , string $ type = 'MAX ' )
506
507
{
@@ -909,9 +910,9 @@ public function orHavingNotIn(?string $key = null, $values = null, ?bool $escape
909
910
*
910
911
* @param array|BaseBuilder|Closure|null $values The values searched on, or anonymous function with subquery
911
912
*
912
- * @return $this
913
- *
914
913
* @throws InvalidArgumentException
914
+ *
915
+ * @return $this
915
916
*/
916
917
protected function _whereIn (?string $ key = null , $ values = null , bool $ not = false , string $ type = 'AND ' , ?bool $ escape = null , string $ clause = 'QBWhere ' )
917
918
{
@@ -1743,9 +1744,9 @@ public function getWhere($where = null, ?int $limit = null, ?int $offset = 0, bo
1743
1744
/**
1744
1745
* Compiles batch insert/update/upsert strings and runs the queries
1745
1746
*
1746
- * @return false|int|string[] Number of rows inserted or FALSE on failure, SQL array when testMode
1747
- *
1748
1747
* @throws DatabaseException
1748
+ *
1749
+ * @return false|int|string[] Number of rows inserted or FALSE on failure, SQL array when testMode
1749
1750
*/
1750
1751
protected function batchExecute (string $ renderMethod , int $ batchSize = 100 )
1751
1752
{
@@ -1858,9 +1859,9 @@ public function setData($set, ?bool $escape = null, string $alias = '')
1858
1859
/**
1859
1860
* Compiles an upsert query and returns the sql
1860
1861
*
1861
- * @return string
1862
- *
1863
1862
* @throws DatabaseException
1863
+ *
1864
+ * @return string
1864
1865
*/
1865
1866
public function getCompiledUpsert ()
1866
1867
{
@@ -1878,17 +1879,24 @@ public function getCompiledUpsert()
1878
1879
*
1879
1880
* @param array|object|null $set
1880
1881
*
1881
- * @return false|int|string[] Number of affected rows or FALSE on failure, SQL array when testMode
1882
- *
1883
1882
* @throws DatabaseException
1883
+ *
1884
+ * @return false|int|string[] Number of affected rows or FALSE on failure, SQL array when testMode
1884
1885
*/
1885
1886
public function upsert ($ set = null , ?bool $ escape = null )
1886
1887
{
1887
- if ($ set === null ) {
1888
- $ set = empty ( $ this -> binds ) ? null : [array_map (static fn ($ columnName ) => $ columnName [0 ], $ this ->binds )];
1888
+ if ($ set === null && ! empty ( $ this -> binds ) ) {
1889
+ $ set = [array_map (static fn ($ columnName ) => $ columnName [0 ], $ this ->binds )];
1889
1890
1890
1891
$ this ->binds = [];
1891
1892
1893
+ $ this ->resetRun ([
1894
+ 'QBSet ' => [],
1895
+ 'QBKeys ' => [],
1896
+ ]);
1897
+ } elseif ($ set === null && ! empty ($ this ->QBSet )) {
1898
+ $ set = [$ this ->QBSet ];
1899
+
1892
1900
$ this ->resetRun ([
1893
1901
'QBSet ' => [],
1894
1902
'QBKeys ' => [],
@@ -1907,9 +1915,9 @@ public function upsert($set = null, ?bool $escape = null)
1907
1915
*
1908
1916
* @param array|object|string|null $set a dataset or select query
1909
1917
*
1910
- * @return false|int|string[] Number of affected rows or FALSE on failure, SQL array when testMode
1911
- *
1912
1918
* @throws DatabaseException
1919
+ *
1920
+ * @return false|int|string[] Number of affected rows or FALSE on failure, SQL array when testMode
1913
1921
*/
1914
1922
public function upsertBatch ($ set = null , ?bool $ escape = null , int $ batchSize = 100 )
1915
1923
{
@@ -2114,9 +2122,9 @@ public function setInsertBatch($key, string $value = '', ?bool $escape = null)
2114
2122
/**
2115
2123
* Compiles an insert query and returns the sql
2116
2124
*
2117
- * @return bool|string
2118
- *
2119
2125
* @throws DatabaseException
2126
+ *
2127
+ * @return bool|string
2120
2128
*/
2121
2129
public function getCompiledInsert (bool $ reset = true )
2122
2130
{
@@ -2147,9 +2155,9 @@ public function getCompiledInsert(bool $reset = true)
2147
2155
*
2148
2156
* @param array|object|null $set
2149
2157
*
2150
- * @return bool
2151
- *
2152
2158
* @throws DatabaseException
2159
+ *
2160
+ * @return bool
2153
2161
*/
2154
2162
public function insert ($ set = null , ?bool $ escape = null )
2155
2163
{
@@ -2237,9 +2245,9 @@ protected function _insert(string $table, array $keys, array $unescapedKeys): st
2237
2245
/**
2238
2246
* Compiles a replace into string and runs the query
2239
2247
*
2240
- * @return BaseResult|false|Query|string
2241
- *
2242
2248
* @throws DatabaseException
2249
+ *
2250
+ * @return BaseResult|false|Query|string
2243
2251
*/
2244
2252
public function replace (?array $ set = null )
2245
2253
{
@@ -2490,10 +2498,10 @@ protected function _updateBatch(string $table, array $keys, array $values): stri
2490
2498
*
2491
2499
* @param array|object $key
2492
2500
*
2493
- * @return $this
2494
- *
2495
2501
* @throws DatabaseException
2496
2502
*
2503
+ * @return $this
2504
+ *
2497
2505
* @deprecated
2498
2506
*/
2499
2507
public function setUpdateBatch ($ key , string $ index = '' , ?bool $ escape = null )
@@ -2576,9 +2584,9 @@ public function getCompiledDelete(bool $reset = true): string
2576
2584
*
2577
2585
* @param mixed $where
2578
2586
*
2579
- * @return bool|string
2580
- *
2581
2587
* @throws DatabaseException
2588
+ *
2589
+ * @return bool|string
2582
2590
*/
2583
2591
public function delete ($ where = '' , ?int $ limit = null , bool $ resetData = true )
2584
2592
{
0 commit comments