@@ -290,16 +290,12 @@ private static function isComparisonOperator(mixed $comparator): bool
290290 return false ;
291291 }
292292
293- return in_array (
294- Str::upper ($ comparator ),
295- [
293+ return in_array (Str::upper ($ comparator ), [
296294 '= ' , '> ' , '< ' , '>= ' , '=< ' , '<> ' , '!= ' , 'LIKE ' , 'NOT ' , 'IS NOT ' , "IN " , "NOT IN " ,
297295 'ILIKE ' , '& ' , '| ' , '<< ' , '>> ' , 'NOT LIKE ' ,
298296 '&& ' , '@> ' , '<@ ' , '? ' , '?| ' , '?& ' , '|| ' , '- ' , '@? ' , '@@ ' , '#- ' ,
299297 'IS DISTINCT FROM ' , 'IS NOT DISTINCT FROM ' ,
300- ],
301- true
302- );
298+ ], true );
303299 }
304300
305301 /**
@@ -397,15 +393,14 @@ public function setTable(string $table): QueryBuilder
397393 * WHERE column IS NULL
398394 *
399395 * @param string $column
400- * @param string $boolean
401396 * @return QueryBuilder
402397 */
403- public function whereNull (string $ column, string $ boolean = ' and ' ): QueryBuilder
398+ public function whereNull (string $ column ): QueryBuilder
404399 {
405400 if (is_null ($ this ->where )) {
406401 $ this ->where = $ column . ' is null ' ;
407402 } else {
408- $ this ->where .= ' ' . $ boolean . ' ' . $ column . ' is null ' ;
403+ $ this ->where .= ' and ' . $ column . ' is null ' ;
409404 }
410405
411406 return $ this ;
@@ -416,16 +411,15 @@ public function whereNull(string $column, string $boolean = 'and'): QueryBuilder
416411 *
417412 * WHERE column NOT NULL
418413 *
419- * @param $column
420- * @param string $boolean
414+ * @param string $column
421415 * @return QueryBuilder
422416 */
423- public function whereNotNull ($ column , $ boolean = ' and ' ): QueryBuilder
417+ public function whereNotNull (string $ column ): QueryBuilder
424418 {
425419 if (is_null ($ this ->where )) {
426420 $ this ->where = $ column . ' is not null ' ;
427421 } else {
428- $ this ->where .= ' ' . $ boolean . ' ' . $ column . ' is not null ' ;
422+ $ this ->where .= ' and ' . $ column . ' is not null ' ;
429423 }
430424
431425 return $ this ;
@@ -440,7 +434,14 @@ public function whereNotNull($column, $boolean = 'and'): QueryBuilder
440434 */
441435 public function whereNotBetween (string $ column , array $ range ): QueryBuilder
442436 {
443- $ this ->whereBetween ($ column , $ range , 'not ' );
437+ $ range = (array ) $ range ;
438+ $ between = implode (' and ' , $ range );
439+
440+ if (is_null ($ this ->where )) {
441+ $ this ->where = $ column . ' not between ' . $ between ;
442+ } else {
443+ $ this ->where .= ' and ' . $ column . ' not between ' . $ between ;
444+ }
444445
445446 return $ this ;
446447 }
@@ -452,32 +453,36 @@ public function whereNotBetween(string $column, array $range): QueryBuilder
452453 *
453454 * @param string $column
454455 * @param array $range
455- * @param string $boolean
456456 * @return QueryBuilder
457- * @throws QueryBuilderException
458457 */
459- public function whereBetween (string $ column , array $ range, string $ boolean = ' and ' ): QueryBuilder
458+ public function whereBetween (string $ column , array $ range ): QueryBuilder
460459 {
461- $ range = (array )$ range ;
460+ $ range = (array ) $ range ;
462461 $ between = implode (' and ' , $ range );
463462
464463 if (is_null ($ this ->where )) {
465- if ($ boolean == 'not ' ) {
466- $ this ->where = $ column . ' not between ' . $ between ;
467- } else {
468- $ this ->where = $ column . ' between ' . $ between ;
469- }
464+ $ this ->where = $ column . ' between ' . $ between ;
470465 } else {
471- if ($ boolean == 'not ' ) {
472- $ this ->where .= ' and ' . $ column . ' not between ' . $ between ;
473- } else {
474- $ this ->where .= ' ' . $ boolean . ' ' . $ column . ' between ' . $ between ;
475- }
466+ $ this ->where .= ' and ' . $ column . ' between ' . $ between ;
476467 }
477468
478469 return $ this ;
479470 }
480471
472+ /**
473+ * WHERE column NOT BETWEEN '' AND ''
474+ *
475+ * @param string $column
476+ * @param mixed $value
477+ * @return QueryBuilder
478+ */
479+ public function whereDifferent (string $ column , mixed $ value ): QueryBuilder
480+ {
481+ $ this ->where ($ column , '<> ' , $ value );
482+
483+ return $ this ;
484+ }
485+
481486 /**
482487 * Where clause with <<not in>> comparison
483488 *
@@ -488,7 +493,25 @@ public function whereBetween(string $column, array $range, string $boolean = 'an
488493 */
489494 public function whereNotIn (string $ column , array $ range )
490495 {
491- $ this ->whereIn ($ column , $ range , 'not ' );
496+ if ($ range instanceof QueryBuilder) {
497+ $ range = "( " . $ range ->toSql () . ") " ;
498+ }
499+
500+ if (is_array ($ range )) {
501+ $ range = (array )$ range ;
502+ $ this ->where_data_binding = array_merge ($ this ->where_data_binding , $ range );
503+
504+ $ map = array_map (fn () => '? ' , $ range );
505+ $ in = implode (', ' , $ map );
506+ } else {
507+ $ in = (string ) $ range ;
508+ }
509+
510+ if (is_null ($ this ->where )) {
511+ $ this ->where = $ column . ' not in ( ' . $ in . ') ' ;
512+ } else {
513+ $ this ->where .= ' and ' . $ column . ' not in ( ' . $ in . ') ' ;
514+ }
492515
493516 return $ this ;
494517 }
@@ -498,11 +521,10 @@ public function whereNotIn(string $column, array $range)
498521 *
499522 * @param string $column
500523 * @param array $range
501- * @param string $boolean
502524 * @return QueryBuilder
503525 * @throws QueryBuilderException
504526 */
505- public function whereIn (string $ column , array $ range, string $ boolean = ' and ' ): QueryBuilder
527+ public function whereIn (string $ column , array $ range ): QueryBuilder
506528 {
507529 if ($ range instanceof QueryBuilder) {
508530 $ range = "( " . $ range ->toSql () . ") " ;
@@ -515,21 +537,13 @@ public function whereIn(string $column, array $range, string $boolean = 'and'):
515537 $ map = array_map (fn () => '? ' , $ range );
516538 $ in = implode (', ' , $ map );
517539 } else {
518- $ in = (string )$ range ;
540+ $ in = (string ) $ range ;
519541 }
520542
521543 if (is_null ($ this ->where )) {
522- if ($ boolean == 'not ' ) {
523- $ this ->where = $ column . ' not in ( ' . $ in . ') ' ;
524- } else {
525- $ this ->where = $ column . ' in ( ' . $ in . ') ' ;
526- }
544+ $ this ->where = $ column . ' in ( ' . $ in . ') ' ;
527545 } else {
528- if ($ boolean == 'not ' ) {
529- $ this ->where .= ' and ' . $ column . ' not in ( ' . $ in . ') ' ;
530- } else {
531- $ this ->where .= ' and ' . $ column . ' in ( ' . $ in . ') ' ;
532- }
546+ $ this ->where .= ' and ' . $ column . ' in ( ' . $ in . ') ' ;
533547 }
534548
535549 return $ this ;
@@ -727,8 +741,8 @@ public function orOn(string $first, $comparator = '=', $second = null): QueryBui
727741 /**
728742 * Clause Group By
729743 *
730- * @param string $column
731- * @return QueryBuilder
744+ * @param string $column
745+ * @return QueryBuilder
732746 * @deprecated
733747 */
734748 public function group ($ column )
0 commit comments