Welcome Guest, Not a member yet? Register   Sign In
Active Record: WHERE(.. OR ..) AND ..
#4

[eluser]wowdezign[/eluser]
This kind of stuff is exactly why I am starting to use more and more query binding.

Your query above is almost already written to bind:

Code:
$sql="SELECT * FROM table WHERE id = ? AND (status = ? OR ip = ?)";
$bind =  array($id,$status,$ip);
$this->db->get($sql,$bind);

If you aren't passing in variables, I've had success with:

Code:
$sql="SELECT * FROM table WHERE id = 3 AND (status = 'somstatus' OR ip = 'x.x.x.x')";
$bind =  array();
$this->db->get($sql,$bind);

I used to love active record. But, when I have a complex query, it's too hard for me to convert it. Since binding does the same thing, I just use it. :-)

It's mentioned at the very bottom of this page in the manual:

http://ellislab.com/codeigniter/user-gui...eries.html


Messages In This Thread
Active Record: WHERE(.. OR ..) AND .. - by El Forum - 11-10-2009, 12:03 PM
Active Record: WHERE(.. OR ..) AND .. - by El Forum - 11-10-2009, 03:14 PM
Active Record: WHERE(.. OR ..) AND .. - by El Forum - 11-10-2009, 03:39 PM
Active Record: WHERE(.. OR ..) AND .. - by El Forum - 11-10-2009, 03:39 PM
Active Record: WHERE(.. OR ..) AND .. - by El Forum - 11-10-2009, 03:45 PM



Theme © iAndrew 2016 - Forum software by © MyBB