In one of my CodeIgniter based application, I store the country data in a column as comma separated value [It is possible to pass multiple country from front-end and rather using another table as mapping (using foreign_key) I use one single table].
To fetch the result in a search page, I wrote the following query:
$this->db->like('country', $country_id);
What the problem I face is, suppose row_1 contains the following data for my target column: 1,3,17 and now if I pass $country_id = 7, it fetches row_1, although row_1 does not directly have 7 (but have 17)...
I know that the problem occurs as CodeIgniter converts my query as %7%.
So my question: Is there any way to omit % character from before and after the search_creteria in CodeIgniter?
I mean, CodeIgniter will convert my query as:
SELECT * FROM table_name WHERE country LIKE '7'
rather (what is currently do):
SELECT * FROM table_name WHERE country LIKE '%7%'
- Thanks