• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.