@@ -141,6 +141,9 @@ protected function startLog()
141
141
$ this ->log = true ;
142
142
}
143
143
144
+ /**
145
+ * Executes the prepared query.
146
+ */
144
147
public function execute ()
145
148
{
146
149
$ query = $ this ->queryBuilder ();
@@ -337,7 +340,7 @@ public function delete()
337
340
* @param $type This is either OR or AND
338
341
* @return $this
339
342
*/
340
- private function whereProcessor ($ args , $ type )
343
+ private function whereProcessor ($ args , $ type, ? bool $ null = false )
341
344
{
342
345
// Check if this where clause is the first
343
346
$ first = false ;
@@ -370,22 +373,91 @@ private function whereProcessor($args, $type)
370
373
}
371
374
$ index ++;
372
375
}
376
+
377
+ return $ this ;
378
+ }
379
+
380
+ private function nullWhereProcessor (string $ column , string $ type , bool $ null ){
381
+ // Check if this where clause is the first
382
+ $ first = false ;
383
+ if ($ this ->_where == "" ) {
384
+ $ first = true ;
385
+ // If it is, append WHERE in the query
386
+ $ this ->_where = " WHERE " ;
387
+ }
388
+
389
+ if ($ first === false ) {
390
+ $ this ->_where .= " $ type " ;
391
+ }
392
+
393
+ if ($ null == false ){
394
+ $ nullString = "IS NOT NULL " ;
395
+ }else {
396
+ $ nullString = "IS NULL " ;
397
+ }
398
+
399
+ $ this ->_where .= " $ column $ nullString " ;
400
+
373
401
return $ this ;
374
402
}
375
403
376
404
/**
377
405
* Generates the where query
406
+ *
378
407
*/
379
408
public function where ()
380
409
{
381
410
return $ this ->whereProcessor (func_get_args (), 'AND ' );
382
411
}
383
412
413
+ /**
414
+ * Generates a where with the OR Operator
415
+ */
384
416
public function orWhere ()
385
417
{
386
418
return $ this ->whereProcessor (func_get_args (), 'OR ' );
387
419
}
388
420
421
+ /**
422
+ * Generates a where for a null column
423
+ *
424
+ * @param string $column The column where the value should be null.
425
+ */
426
+ public function whereNull (string $ column )
427
+ {
428
+ return $ this ->nullWhereProcessor ($ column , 'AND ' , true );
429
+ }
430
+
431
+ /**
432
+ * Generates a where for a null column with the OR operator
433
+ *
434
+ * @param string $column The column where the value should be null.
435
+ */
436
+ public function orWhereNull (string $ column )
437
+ {
438
+ return $ this ->nullWhereProcessor ($ column , 'AND ' , true );
439
+ }
440
+
441
+ /**
442
+ * Generates a where for not null column with the OR operator
443
+ *
444
+ * @param string $column The column where the value should not be null.
445
+ */
446
+ public function whereNotNull (string $ column )
447
+ {
448
+ return $ this ->nullWhereProcessor ($ column , 'AND ' , false );
449
+ }
450
+
451
+ /**
452
+ * Generates a where for not null column with the OR operator
453
+ *
454
+ * @param string $column The column where the value should not be null.
455
+ */
456
+ public function orWhereNotNull (string $ column )
457
+ {
458
+ return $ this ->nullWhereProcessor ($ column , 'AND ' , false );
459
+ }
460
+
389
461
/**
390
462
* whereRaw
391
463
*
0 commit comments