[TYPO3-mvc] Query constraints using MM relations

Jacob Rasmussen jacob at lightbulb.dk
Wed Mar 23 19:55:06 CET 2011


Hi Franz,

> $query->in('sogne.uid', array(1, 2))
>
> Try this, should do the trick, but probably the way you tried it should
> also work.

I found that I need to use $query->contains() in order to get the MM 
lookup, but the contains method can't handle arrays nor QueryResult 
objects - and by debugging a test like this:

$query->contains('sogne', 1) returns a SQL statement like this:
---
SELECT tx_churchbase_bygninger.* FROM tx_churchbase_bygninger WHERE 
tx_churchbase_bygninger.uid IN (SELECT uid_local FROM 
tx_churchbase_sogn_mm WHERE uid_foreign=1) AND 
tx_churchbase_bygninger.deleted=0 AND tx_churchbase_bygninger.hidden=0
---

But this lookup doesn't take MM_match_fields into account, so the query 
returns the wrong elements.

-- 
Kind regards

Jacob Rasmussen
Certified TYPO3 Integrator


More information about the TYPO3-project-typo3v4mvc mailing list