Welcome Guest, Not a member yet? Register   Sign In
Active Record: Brackets in WHERE/HAVING clauses
#1

[eluser]mradlmaier[/eluser]
Hi All,

As far as I can see from the documentation, there is no easy way to use brackets in the WHERE or HAVING clauses to control precedence of multiple column criteria?

For example:

Code:
SELECT * FROM tbl1 WHERE col1 = 'abc' AND col2 = 'edf' OR col3 = 'ghi'

is not the same as

Code:
SELECT * FROM tbl1 WHERE col1 = 'abc' AND (col2 = 'edf' OR col3 = 'ghi')

Or did I miss something?

Michael
#2

[eluser]TheFuzzy0ne[/eluser]
Pass FALSE in as the third parameter to prevent escaping:

Code:
$this->db->where('col1', 'abc', FALSE);


The almighty user guide says:
Quote:$this->db->where() accepts an optional third parameter. If you set it to FALSE, CodeIgniter will not try to protect your field or table names with backticks.

Code:
$this->db->where('MATCH (field) AGAINST ("value")', NULL, FALSE);




Theme © iAndrew 2016 - Forum software by © MyBB