I am trying to form a query using codeigniter’s active record, the search is based on a comma seperated list that user can input.
I know how to get the search criteria out as sepererate values :
$criteria = explode($this->input->post('search_criteria');
What I do not know is how I can create a query in my model that creates a enough where comparisons based on the number of criteria.
So for example if the user were to search for PHP, HTML, Project Management
I would need a query that looks like this,
SELECT * FROM candidates WHERE candidate_job_tags LIKE %PHP% OR WHERE candidate_job_tags LIKE %HTML% OR WHERE candidate_job_tags LIKE %Project Management%
Can this be done?
You can use the Active Record class‘
or_like()method to build that portion of your query:would produce a query that looks like this: