filterByAttribute

Permalink
I want to search the users with the magic method of the user_list model.

This is my code

$userList->filterByAddress('%'.$keywords.'%', 'LIKE');
$userList->filterByZipcode('%'.$keywords.'%', 'LIKE');
$userList->filterByCity('%'.$keywords.'%', 'LIKE');


When using the debug mode of the db class I see that the code creates a mysql_query like this:

... and ak_address = '%keyword%' and ak_zipcode = '%keyword%' and ak_city = '%keyword%'...


Instead of AND I want to use OR in my query. Is there a way to do this without creating another function in the model user_list.php?

DeWebmakers
 
jordanlev replied on at Permalink Reply
jordanlev
I don't think you can do "OR" with the filterBy___ method. I think you can pass in your own SQL query though:
$userList->addToQuery("ak_address LIKE '%keywords%' OR ak_zipcode LIKE '%keywords%'");

(I just saw that in the documentation, haven't tested it out so I'm not sure if it will work).