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

[eluser]Unknown[/eluser]
Hello,

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

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

How can I do this with Active Records class?
#2

[eluser]champs[/eluser]
Code:
$this->db->select('field');
$this->db->where("field1", 1);
$this->db->where("(field2='2' OR field3='3')");

HTH.

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.:

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

[eluser]Unknown[/eluser]
Thanks a lot, champs

This solve all of my problems




Theme © iAndrew 2016 - Forum software by © MyBB