Welcome Guest, Not a member yet? Register   Sign In
Question using 'where'
#1

[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;
$sub_category_id = 2;

$this->db->where(array('category_id' => $category_id , 'sub_category_id' => $sub_category_id ));


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 ));
#2

[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
#3

[eluser]ChiefChirpa[/eluser]
ignore
#4

[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




Theme © iAndrew 2016 - Forum software by © MyBB