jonathangeiger / kohana-jelly

See the link below for the most up-to-date code
https://github.com/creatoro/jelly
MIT License
146 stars 34 forks source link

Question re creating complex queries #185

Closed chiurlo closed 13 years ago

chiurlo commented 13 years ago

Hello! How would I go about creating a query such as this:

SELECT * FROM `things` 
WHERE (`somefield` = $value OR `anotherfield` = $value) 
AND `status` = 'needs attention'

It's the parentheses that I can't figure out.

So far I've got ->where('somefield','=',$value) ->or_where('somefield','=',$value) ->and_where('status','=','needs attention')

but of course that is equivalent to

WHERE `somefield` = $value OR `anotherfield` = $value 
AND `status` = 'needs attention'

and thus retrieves too many results.

Thanks much, Alison

TdroL commented 13 years ago

http://michaeldpeters.com/userguide/guide/api/Database_Query_Builder_Where#where_open

http://michaeldpeters.com/userguide/guide/api/Database_Query_Builder_Where#where_close

chiurlo commented 13 years ago

Thanks TdroL! I should have checked my email earlier -- I just found those pages of the userguide myself, minutes ago. But I really appreciate that you took the time to point me in the right direction.