ParamQuery grid support forum

General Category => Help for ParamQuery Pro => Topic started by: queensgambit9 on March 17, 2021, 03:35:40 pm

Title: Multiple search terms with condition
Post by: queensgambit9 on March 17, 2021, 03:35:40 pm
Hi

For contain condition would it be possible to use keywords to split string to multiple search terms?
Ex:

term1+term2+term3 generates (PHP) query to DB:

Code: [Select]
...WHERE a LIKE '%term1%' AND a LIKE '%term2%' AND a LIKE '%term3%'
instead of

Code: [Select]
...WHERE a LIKE '%term1+term2+term3%'
Title: Re: Multiple search terms with condition
Post by: paramvir on March 18, 2021, 10:03:26 am
yes it's possible to do so by updating FilterHelper::_contain method in PHP code.

Code: [Select]
    public static function _contain($dataIndx, &$fcrule, &$param, $value){
        $_fcrule = array();
        $arr = explode("+", $value);
        foreach ($arr as $val) {
            $_fcrule[] = $dataIndx . " like CONCAT('%', ?, '%')";
            $param[] = $val;
        }
        $fcrule[] = implode(" AND ", $_fcrule);
    }