Best way to use activerecord to look for ID number in JSON encoded string
I am storing JSON strings of ID numb开发者_Go百科ers in my database for some website settings. I need create an active record query to look for an ID number in this string. What's the best way to do this?
Example of stored string:
["25","26","27","28","29"]
I was thinking perhaps:
$this->db->like('settings', '"28"');
However, this seems a little improvised...
I think you are searching for something like:
$this->db->where_in('id', json_decode('["25","26","27","28","29"]'));
精彩评论