Welcome Guest, Not a member yet? Register   Sign In
Multiple Keyword in search
#7

No, that will just get you an error as well.
If you just want to use it directly with explode, you need to specify the index of the array. But you need to check how many keywords you got and add this X times:

PHP Code:
$builder->orLike('bio'$keyword[1]);
$builder->orLike('first_name'$keyword[1]);
$builder->orLike('last_name'$keyword[1]); 

This is for two words. But as you don't know how many keywords there are, you need to do it more dynamic and loop over it.
PHP Code:
$keyword explode(' '$this->request->getVar('key'));

$builder $this->db->table('test');
$builder->like('bio'$keyword[0]);
$builder->orLike('first_name'$keyword[0]);
$builder->orLike('last_name'$keyword[0]);
$builder->orLike('bio'$keyword[1]);
$builder->orLike('first_name'$keyword[1]);
$builder->orLike('last_name'$keyword[1]);
$query $builder->get();

$q $query->getResultArray(); 
Reply


Messages In This Thread
Multiple Keyword in search - by Marcolino92 - 04-16-2020, 01:36 AM
RE: Multiple Keyword in search - by Marcolino92 - 04-18-2020, 12:56 AM
RE: Multiple Keyword in search - by jreklund - 04-18-2020, 07:13 AM
RE: Multiple Keyword in search - by Marcolino92 - 04-18-2020, 07:55 AM
RE: Multiple Keyword in search - by jreklund - 04-18-2020, 09:12 AM
RE: Multiple Keyword in search - by Marcolino92 - 04-18-2020, 09:46 AM
RE: Multiple Keyword in search - by jreklund - 04-18-2020, 01:29 PM



Theme © iAndrew 2016 - Forum software by © MyBB