Welcome Guest, Not a member yet? Register   Sign In
Problems with Active Record


I need some help with this problem, hope that someone can help me

Ok, I need to do a query like this:
SELECT field WHERE field1='1' AND (field2='2' OR field3='3')

How can I do this with Active Records class?

$this->db->where("field1", 1);
$this->db->where("(field2='2' OR field3='3')");


And don't forget, when you do funky things like that in statements, you need to run DB::escape_str() on any input variables you use there, i.e.:

$this->db->where(sprintf("(foo='bar' OR baz='%s')", $this->db->escape_str($this-input->post('whee')))

Thanks a lot, champs

This solve all of my problems

Theme © iAndrew 2016 - Forum software by © MyBB