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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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