Or_where clause won't auto refresh anymore because of the or_where clause

Or_where clause won't auto refresh anymore because of the or_where clause

YoDavishYoDavish Posts: 123Questions: 46Answers: 3
edited February 2022 in DataTables 1.9

Hello i have an or_where clause below that stops datatables editor from refresh after an edit has been made. Below is the code in quesiton. If i comment out the $q->or_where it will auto refresh.

->where( function ($q){                     
           $q->where(function ( $s ) {
                $s->where('Completed', 0);
                $s->where( "ifnull(inactiveflag,'')", '');
           });         
           $q->or_where( function ( $r ) {
                $r->where('Completed', 1);
                $r->where('cmbt_modified_date', 'DATE_ADD( NOW(), INTERVAL -1 DAY )', '>', false);
           });

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,368Questions: 1Answers: 10,449 Site admin
    Answer ✓

    You need to nest it one more level. The Editor->where() method doesn't automatically include parenthesis, but the Query->where() method does!

    This should do it:

    ->where( function ($n){   
         $n->where( function ($q) {                  
               $q->where(function ( $s ) {
                    $s->where('Completed', 0);
                    $s->where( "ifnull(inactiveflag,'')", '');
               });         
               $q->or_where( function ( $r ) {
                    $r->where('Completed', 1);
                    $r->where('cmbt_modified_date', 'DATE_ADD( NOW(), INTERVAL -1 DAY )', '>', false);
               });
         });
    })
    

    Allan

Sign In or Register to comment.