dinamic filter for qty - BETWEEN

Hi ,
Trying to build own filter for numbers . >=,>,<=,< operands works well . Now wanna to add “…” , a la “BETWEEN” . Input of “10…20” must be converted to operation “between” and value “10 and 20” . So I’m analyzing input in $grid->event->attach( “beforeFilter”, “grid_serv_filter” ) :

   ...
         $lst  = true;
         $p    = 0;
         $cVal = $filter_by->rules[ $index ][ "value" ];
         $val1 = '';
         $rul1 = '';
         if ( strpos( $cVal, ".." ) !== false )
         {
            $p    = strpos( $cVal, ".." );
            if ( strlen( $cVal ) > $p + 2 ) // if it more than '10..'
            {
               $lst = false; // to avoid smallest a2 
               $a1  = intval( substr( $cVal, 0, $p - 1 ) );
               $a2  = intval( substr( $cVal, $p + 2 ) );
               ChromePhp::log( ".. - ".$cVal." p - ".$p." , a1 - ".$a1." , a2 - ".$a2 );
               if ( $a2 > $a1  )
               {
                  $val1 = substr( $cVal, 0, $p - 1 ) + " and " + substr( $cVal, $p + 2 );
                  $rul1 = "between";
                  $lst  = true; // can be filtered ...
               }
            }
         }

   ...

         if ( $lst == true )
         {
            if ( strlen( $val1 ) == 0 ) // only quantity no operands 
               $filter_by->rules[ $index ][ "operation" ] = " = ";
            else // exist operands ...
            {
               $filter_by->rules[ $index ][ "operation" ] = " ".$rul1." ";
               $filter_by->rules[ $index ][ "value" ] = $val1;
            }
         }

But I’m geting an error of db_msqli.php “Fatal error … bla bla … line 15 …” . I can understand that here is a problem of value “10 and 20” ( for sample ) . But don’t know how to pass 2 values for that …

With best regards !

Please, try to enable logging to see the detailed information about the error:
docs.dhtmlx.com/doku.php?id=dhtm … tor:errors

Thanks , sematik, for your sugestion … It’s more clear . At first was mine error . But now I run into dilemma . For filter it must be directed both - rule and value . If direct rule ‘between’ and then value ‘10…20’ then it will return error , because select query at the end will be “where ‘uzs_kiekis’ between ‘10 and 20’ limit 1,100” . If to direct only rule "between “.$a1.” and ".$a2; and value = ‘’ , then select of query will not display that because value is empty …

Insert this query piece into main select ? How that can be done ? I want to do that in automatic mode . Nothing raised such question with number filtering possibilities ? :slight_smile:

With best regards !

I found this in forum - viewtopic.php?f=2&t=23069&p=76990&hilit=beforeFilter#p76990 . and this
viewtopic.php?f=2&t=23068&p=74161&hilit=beforeFilter#p74161

After that I did :

                  $filter_by->rules[ $index ][ "operation" ] = ">=";
                  $filter_by->rules[ $index ][ "value" ]  = $a1;
                  $filter_by->add("uzs_kiekis", $a2, "<=" );

Works fine ! Only one question - this added second rule will not disturb later ? It seems that all is working OK and other request is working …

With best regards !