@@ -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 ;
@@ -928,7 +928,7 @@ public function orHavingNotIn(?string $key = null, $values = null, ?bool $escape
928928 */
929929 protected function _whereIn (?string $ key = null , $ values = null , bool $ not = false , string $ type = 'AND ' , ?bool $ escape = null , string $ clause = 'QBWhere ' )
930930 {
931- if (empty ( $ key) || ! is_string ($ key )) {
931+ if ($ key === null || $ key === '' || $ key === ' 0 ' || ! is_string ($ key )) {
932932 throw new InvalidArgumentException (sprintf ('%s() expects $key to be a non-empty string ' , debug_backtrace (0 , 2 )[1 ]['function ' ]));
933933 }
934934
@@ -1434,7 +1434,7 @@ public function orHaving($key, $value = null, ?bool $escape = null)
14341434 public function orderBy (string $ orderBy , string $ direction = '' , ?bool $ escape = null )
14351435 {
14361436 $ qbOrderBy = [];
1437- if (empty ( $ orderBy) ) {
1437+ if ($ orderBy === '' || $ orderBy === ' 0 ' ) {
14381438 return $ this ;
14391439 }
14401440
@@ -1490,7 +1490,7 @@ public function limit(?int $value = null, ?int $offset = 0)
14901490 $ this ->QBLimit = $ value ;
14911491 }
14921492
1493- if (! empty ( $ offset) ) {
1493+ if ($ offset !== null && $ offset !== 0 ) {
14941494 $ this ->QBOffset = $ offset ;
14951495 }
14961496
@@ -1504,7 +1504,7 @@ public function limit(?int $value = null, ?int $offset = 0)
15041504 */
15051505 public function offset (int $ offset )
15061506 {
1507- if (! empty ( $ offset) ) {
1507+ if ($ offset !== 0 ) {
15081508 $ this ->QBOffset = (int ) $ offset ;
15091509 }
15101510
@@ -1736,7 +1736,7 @@ public function getWhere($where = null, ?int $limit = null, ?int $offset = 0, bo
17361736 $ this ->where ($ where );
17371737 }
17381738
1739- if (! empty ( $ limit) ) {
1739+ if ($ limit !== null && $ limit !== 0 ) {
17401740 $ this ->limit ($ limit , $ offset );
17411741 }
17421742
@@ -2452,7 +2452,7 @@ public function update($set = null, $where = null, ?int $limit = null): bool
24522452 $ this ->where ($ where );
24532453 }
24542454
2455- if (! empty ( $ limit) ) {
2455+ if ($ limit !== null && $ limit !== 0 ) {
24562456 if (! $ this ->canLimitWhereUpdates ) {
24572457 throw new DatabaseException ('This driver does not allow LIMITs on UPDATE queries using WHERE. ' );
24582458 }
@@ -2762,7 +2762,7 @@ public function delete($where = '', ?int $limit = null, bool $resetData = true)
27622762
27632763 $ sql = $ this ->_delete ($ this ->removeAlias ($ table ));
27642764
2765- if (! empty ( $ limit) ) {
2765+ if ($ limit !== null && $ limit !== 0 ) {
27662766 $ this ->QBLimit = $ limit ;
27672767 }
27682768
@@ -3172,7 +3172,7 @@ protected function compileGroupBy(): string
31723172 */
31733173 protected function compileOrderBy (): string
31743174 {
3175- if (is_array ($ this ->QBOrderBy ) && ! empty ( $ this ->QBOrderBy ) ) {
3175+ if (is_array ($ this ->QBOrderBy ) && $ this ->QBOrderBy !== [] ) {
31763176 foreach ($ this ->QBOrderBy as &$ orderBy ) {
31773177 if ($ orderBy ['escape ' ] !== false && ! $ this ->isLiteral ($ orderBy ['field ' ])) {
31783178 $ orderBy ['field ' ] = $ this ->db ->protectIdentifiers ($ orderBy ['field ' ]);
@@ -3265,10 +3265,10 @@ protected function isLiteral(string $str): bool
32653265 {
32663266 $ str = trim ($ str );
32673267
3268- if (empty ( $ str)
3269- || ctype_digit ($ str )
3270- || (string ) (float ) $ str === $ str
3271- || in_array (strtoupper ($ str ), ['TRUE ' , 'FALSE ' ], true )
3268+ if ($ str === '' || $ str === ' 0 '
3269+ || ctype_digit ($ str )
3270+ || (string ) (float ) $ str === $ str
3271+ || in_array (strtoupper ($ str ), ['TRUE ' , 'FALSE ' ], true )
32723272 ) {
32733273 return true ;
32743274 }
0 commit comments