Welcome Guest, Not a member yet? Register   Sign In
CI Query --help required
#1

[eluser]Computerzworld[/eluser]
Hello,
I am having one query in which there is one or condition & one and condition. Here is the format of my query.

Code:
$this->db->where('field1',$this->field1);
$this->db->or_where('field2',$this->field2);
$this->db->where('field3',$this->field3);
$query = $this->db->get('users');

And if I echo this query it gives result something like this.

Code:
$query = "select * from users where field1 = '".$this->field1."'" or field2 = '".$this->field2."' and field3 = '".$this->field3."'";

And hence it contains no brackets between or conditions , and condition is neglected. Is there anyway so that i can have brackets outside the query in CI format so that or condition is grouped alongwith and condition something like this...

Code:
$query = "select * from users where (field1 = '".$this->field1."'" or field2 = '".$this->field2."') and field3 = '".$this->field3."'";

How can I write such query using CI? Please help me. Thanks in advance....


Messages In This Thread
CI Query --help required - by El Forum - 02-14-2009, 02:38 AM
CI Query --help required - by El Forum - 02-14-2009, 04:04 AM
CI Query --help required - by El Forum - 02-14-2009, 05:05 AM
CI Query --help required - by El Forum - 02-14-2009, 05:16 AM
CI Query --help required - by El Forum - 02-14-2009, 05:18 AM
CI Query --help required - by El Forum - 02-14-2009, 05:22 AM
CI Query --help required - by El Forum - 02-14-2009, 06:36 AM



Theme © iAndrew 2016 - Forum software by © MyBB