[TYPO3-mvc] Multiple constraints result in query error

Sebastian Schreiber me at schreibersebastian.de
Thu Oct 20 08:13:38 CEST 2011


Am 19.10.2011 23:38, schrieb Henjo Hoeksma:
> 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%')
>>     )
>> );
>
>
> _______________________________________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc
Dear Henjo,
it is always nice to share your solutions ;-)

-- 
Sebastian Schreiber
(Medieninformatiker B.Sc.)
(TYPO3 Certified Integrator)

Schanzenstraße 27, Schlosserei 4
D-51063 Köln

T  0221 677 88 541
M  0176 431 05 790

Skype schreibersebastian.de

me at schreibersebastian.de
www.schreibersebastian.de

Steuernummer: 217 / 5269 / 4675



More information about the TYPO3-project-typo3v4mvc mailing list