[TYPO3-mvc] logicalAnd with multiple conditions

Dmitri Pisarev dimaip at gmail.com
Mon Apr 25 14:43:45 CEST 2011


On 25.04.2011 16:34, Steffen Ritter wrote:
> Am 25.04.2011 14:26, schrieb Dmitri Pisarev:
>> Hi dear community!
>> I'm back to extbase development after a serious break, and here's the
>> question I can't figure out:
>> I need to build query with many filters. Ofcourse this doesn't work:
>> foreach ($filters as $filter) {
>> $str = '%' . $filter['data']['value'] . '%';
>> $query->matching($query->like($filter['field'], $str));
>> }
>>
>> Then how do I do it? logicalAnd receives only two operands, and even if
>> it did receive many, then how do I apply them in a loop?
>>
>> Thanks in advance.
>>
>> Happy Easter!
>> Dmitri Pisarev.
> logicalAnd also is able to process an array.
>
> regards
>
> Steffen
Many thanks, Steffen! It worked indeed. Somehow I couldn't figure it out 
from the source...
Here's the solution that works:
foreach ($filters as $filter) {
	$str = '%' . $filter['data']['value'] . '%';
	$filter_array[] = $query->like($filter['field'], $str);
}
$query->matching($query->logicalAnd($filter_array));

Regards,
Dmitri Pisarev.


More information about the TYPO3-project-typo3v4mvc mailing list