mikecao / sparrow

A simple database toolkit for PHP
MIT License
289 stars 68 forks source link

Add parenthesis #30

Closed kamov closed 7 years ago

kamov commented 7 years ago

I have a query with different filter in where clausole. I would like to do something like below:

SELECT * FROM table WHERE status=1 AND (title LIKE '%test%' OR content='%test%') AND category_id=2

I have do like this:

$db->from('table') ->where('status', 1) ->where('title %', '%test%') ->where('|content', '%test%') ->where('category_id', 2) ;

But this return without parentesis, like below:

SELECT * FROM table WHERE status=1 AND title LIKE '%test%' OR content='%test%' AND category_id=2

mikecao commented 7 years ago

Sparrow doesn't support complex queries like that. You would have to just pass your entire where clause as a string.

kamov commented 7 years ago

Thanks, work fine!