[TYPO3-mvc] Persistence_rewrite merged!
Jochen Rau
jochen.rau at typoplanet.de
Tue Jul 14 15:41:17 CEST 2009
Hi Frans.
Frans van der Veen wrote:
> And finally:
> What would be the best way to create multiple OR / ANDs in a query:
> select * from table where column1 like '%test%' or column2 like '%test%'
> or column3 like '%test%'?
>
> Doing it like this works:
> $query->matching(
> $query->logicalOr(
> $query->like('column1', '%test%'),
> $query->logicalOr(
> $query->like('column2', '%test%'),$query->like('column3', '%test%')
> )
> )
> The downside it adds extra '()' to the query, which could lead to
> undesired results. Is this the way you intended it to work?
Yes, it results in
... WHERE (tx_blogexample_domain_model_blog.column1 LIKE "%test%" OR
(tx_blogexample_domain_model_blog.column2 LIKE "%test%" OR
tx_blogexample_domain_model_blog.column3 LIKE "%test%"))
which is the intended result. It is like the polish notation
(http://en.wikipedia.org/wiki/Polish_notation).
Regards
Jochen
--
Every nit picked is a bug fixed
More information about the TYPO3-project-typo3v4mvc
mailing list