[TYPO3-mvc] Multiple constraints result in query error
Henjo Hoeksma
me at henjohoeksma.nl
Wed Oct 19 23:38:32 CEST 2011
Hi Franz,
found the problem. Code works great. It was something else that was in the way…
One of those great moments ;-)
Thanks though!
Henjo
On 2011-10-19 09:47:13 +0000, Franz Koch said:
> Hi Henjo,
>
>> I try to parse an array of fields dynamically to a logicalAnd statement,
>> but somehow my query gets messed up...
>> I don't see where it goes wrong, I hope you can help me!
>>
>> This is a snippet of my repository function:
> ...
>> $constraints_array = array();
>> foreach ($fields as $key => $value) {
>> $constraints_array[] = $query->like($key, '%'.$value.'%');
>> }
>> $query->matching($query->logicalAnd($constraints_array));
>
> code looks good.
>
>> For a single entry in the $fields array this works fine.
>> When using a second entry in my filter box that adds a second entry in
>> the array, somehow the query get's messed up and makes it like:
>>
>> tx_extension_domain_model_objet.key1_and_key2
>>
>> So the keys get combined instead of 2 seperate ones:
>>
>> tx_extension_domain_model_objet.key1 LIKE ''
>> AND
>> tx_extension_domain_model_objet.key2 LIKE ''
>>
>> Does anyone have a clue on why this happens?
>
> what version of Extbase are you using? 1.4dev? What happens if you try
>
> $query->matching(
> $query->logicalAnd(
> $query->like($key, '%foo%'),
> $query->line($key, '%bar%')
> )
> );
More information about the TYPO3-project-typo3v4mvc
mailing list