Question using 'where' |
[eluser]chefnelone[/eluser]
Hello Before reinventing the wheel; I'd like to know if is there something within the Active Record features or other helper, class, ... to do this. I have this line which works fine if the fields' table: category_id and sub_category_id contain interger numbers (like: 1, 2, 3,...). Code: $category_id = 1; But I have serialized arrays in those fields. Something like: a:1:{i:0;s:3:"228";} which when unserialized is something like: ('1','2','5') What I need to do is to create a 'where' statement meaning: 'where the array category_id contains $category_id and the array sub_category_id contains $sub_category_id'. Something like: Code: $this->db->where(array('category_id' CONTAINS $category_id, 'sub_category_id' CONTAINS $sub_category_id ));
[eluser]danmontgomery[/eluser]
MySQL doesn't have any serialize/unserialize functionality. You would need to extract that data and use where_in() http://ellislab.com/codeigniter/user-gui...ecord.html
[eluser]chefnelone[/eluser]
[quote author="noctrum" date="1265314994"]MySQL doesn't have any serialize/unserialize functionality. You would need to extract that data and use where_in() http://ellislab.com/codeigniter/user-gui...ecord.html[/quote] Ok, thanks |
Welcome Guest, Not a member yet? Register Sign In |