[TYPO3-mvc] Selecting records which have MM relations to another table

Jan-Erik Revsbech janerik at mocsystems.com
Fri Dec 18 13:53:18 CET 2009


I have two classes Document and DocumentCategory objects and corresponding
tables. The field categories on the Document table/object is a MM relation
to DocumentCategory and this all works fine. Calling
$document->getCategories() returns me correctly the the categories of the
document.

 

Now I need to make an action on my Documentcontroller that lists all
Documents in a given category (or several categories actually). How do I do
this? Using

 

$this->documentRepository =
t3lib_div::makeInstance('Tx_applusDocument_Domain_Repository_DocumentReposit
ory');

$Query = $this->documentRepository->createQuery();

$Query->matching($Query->equals('category',$category));

 

I  hopefully (and a little naively) expetected to get the document which
have $category as their category? However this is is not the case. Do I
somehow need to join the MM table on the query?

 

Regards

Jan-Erik Revsbech

MOC Systems

 



More information about the TYPO3-project-typo3v4mvc mailing list