Welcome Guest, Not a member yet? Register   Sign In
Query builder with round brackets
#1

[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
#2

[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.




Theme © iAndrew 2016 - Forum software by © MyBB