@@ -318,7 +318,7 @@ public function __construct($tableName, ConnectionInterface $db, ?array $options
318318
319319 $ this ->from ($ tableName );
320320
321- if (! empty ( $ options) ) {
321+ if ($ options !== null && $ options !== [] ) {
322322 foreach ($ options as $ key => $ value ) {
323323 if (property_exists ($ this , $ key )) {
324324 $ this ->{$ key } = $ value ;
@@ -920,6 +920,7 @@ public function orHavingNotIn(?string $key = null, $values = null, ?bool $escape
920920 * @used-by whereNotIn()
921921 * @used-by orWhereNotIn()
922922 *
923+ * @param non-empty-string|null $key
923924 * @param array|BaseBuilder|Closure|null $values The values searched on, or anonymous function with subquery
924925 *
925926 * @return $this
@@ -928,7 +929,7 @@ public function orHavingNotIn(?string $key = null, $values = null, ?bool $escape
928929 */
929930 protected function _whereIn (?string $ key = null , $ values = null , bool $ not = false , string $ type = 'AND ' , ?bool $ escape = null , string $ clause = 'QBWhere ' )
930931 {
931- if (empty ( $ key) || ! is_string ( $ key) ) {
932+ if ($ key === null || $ key === '' ) {
932933 throw new InvalidArgumentException (sprintf ('%s() expects $key to be a non-empty string ' , debug_backtrace (0 , 2 )[1 ]['function ' ]));
933934 }
934935
@@ -1434,7 +1435,7 @@ public function orHaving($key, $value = null, ?bool $escape = null)
14341435 public function orderBy (string $ orderBy , string $ direction = '' , ?bool $ escape = null )
14351436 {
14361437 $ qbOrderBy = [];
1437- if (empty ( $ orderBy) ) {
1438+ if ($ orderBy === '' ) {
14381439 return $ this ;
14391440 }
14401441
@@ -1490,7 +1491,7 @@ public function limit(?int $value = null, ?int $offset = 0)
14901491 $ this ->QBLimit = $ value ;
14911492 }
14921493
1493- if (! empty ( $ offset) ) {
1494+ if ($ offset !== null && $ offset !== 0 ) {
14941495 $ this ->QBOffset = $ offset ;
14951496 }
14961497
@@ -1504,8 +1505,8 @@ public function limit(?int $value = null, ?int $offset = 0)
15041505 */
15051506 public function offset (int $ offset )
15061507 {
1507- if (! empty ( $ offset) ) {
1508- $ this ->QBOffset = ( int ) $ offset ;
1508+ if ($ offset !== 0 ) {
1509+ $ this ->QBOffset = $ offset ;
15091510 }
15101511
15111512 return $ this ;
@@ -1736,7 +1737,7 @@ public function getWhere($where = null, ?int $limit = null, ?int $offset = 0, bo
17361737 $ this ->where ($ where );
17371738 }
17381739
1739- if (! empty ( $ limit) ) {
1740+ if ($ limit !== null && $ limit !== 0 ) {
17401741 $ this ->limit ($ limit , $ offset );
17411742 }
17421743
@@ -2452,7 +2453,7 @@ public function update($set = null, $where = null, ?int $limit = null): bool
24522453 $ this ->where ($ where );
24532454 }
24542455
2455- if (! empty ( $ limit) ) {
2456+ if ($ limit !== null && $ limit !== 0 ) {
24562457 if (! $ this ->canLimitWhereUpdates ) {
24572458 throw new DatabaseException ('This driver does not allow LIMITs on UPDATE queries using WHERE. ' );
24582459 }
@@ -2762,7 +2763,7 @@ public function delete($where = '', ?int $limit = null, bool $resetData = true)
27622763
27632764 $ sql = $ this ->_delete ($ this ->removeAlias ($ table ));
27642765
2765- if (! empty ( $ limit) ) {
2766+ if ($ limit !== null && $ limit !== 0 ) {
27662767 $ this ->QBLimit = $ limit ;
27672768 }
27682769
@@ -3172,7 +3173,7 @@ protected function compileGroupBy(): string
31723173 */
31733174 protected function compileOrderBy (): string
31743175 {
3175- if (is_array ($ this ->QBOrderBy ) && ! empty ( $ this ->QBOrderBy ) ) {
3176+ if (is_array ($ this ->QBOrderBy ) && $ this ->QBOrderBy !== [] ) {
31763177 foreach ($ this ->QBOrderBy as &$ orderBy ) {
31773178 if ($ orderBy ['escape ' ] !== false && ! $ this ->isLiteral ($ orderBy ['field ' ])) {
31783179 $ orderBy ['field ' ] = $ this ->db ->protectIdentifiers ($ orderBy ['field ' ]);
@@ -3265,7 +3266,7 @@ protected function isLiteral(string $str): bool
32653266 {
32663267 $ str = trim ($ str );
32673268
3268- if (empty ( $ str)
3269+ if ($ str === ''
32693270 || ctype_digit ($ str )
32703271 || (string ) (float ) $ str === $ str
32713272 || in_array (strtoupper ($ str ), ['TRUE ' , 'FALSE ' ], true )
0 commit comments