CodeIgniter Forums
Query builder with round brackets - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Query builder with round brackets (/showthread.php?tid=13660)



Query builder with round brackets - El Forum - 12-01-2008

[eluser]P.T.[/eluser]
Hello,

I am currenty stuck with a problem I can't figure out.
I was unable to find a solution searching, so I hope one of you can help me out.

A part of what I have is this:
->where('items', 0)
->like('sTitle', 'test')
->orlike('sDescription', 'test')


Now it generates a query like this:

WHERE items = '0' AND sTitle LIKE '%test%' OR sDescription LIKE '%test%'

This isn't what I want to get, since it will take all items. No matter if it's 0 or not, while he finds "test" in sTitle or sDescription.

What I want to reach is this:

WHERE items = '0' AND (sTitle LIKE '%test%' OR sDescription LIKE '%test%')

Is this somehow possible with the query builder inside codeigniter?

Thanks for all the help and information Smile


Query builder with round brackets - El Forum - 12-01-2008

[eluser]m4rw3r[/eluser]
I've made a SQL-builder which is capable of this: IgnitedQuery.

You can find the source here (download at the bottom of the page).

It works like CI's ActiveRecord, but it is also capable of handling subqueries and nested wheres.
I haven't made a large manual for it, but here is a short one for the subqueries and nested where statements.