[TYPO3-mvc] Multiple constraints result in query error

Franz Koch typo3.RemoveForMessage at elements-net.de
Wed Oct 19 11:47:13 CEST 2011


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%')
	)
);

-- 
kind regards,
Franz Koch


More information about the TYPO3-project-typo3v4mvc mailing list