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

Sebastian Kurfürst sebastian at typo3.org
Fri Dec 18 16:58:56 CET 2009


Hey,


> 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();
Does this work? I thought createQuery() was protected, and not public.
Definitely it should be protected.

Currently you create the query inside your controller, but you should
rather create a custom method inside your repository, where you build
the query, and execute it. In case you cannot find "the extbase way" of
creating a query, you can use $query->statement("...") to directly write
a SQL query. But watch out because of SQL injections and the like ;-)

Hope this made stuff a bit clearer :)

Greets,
Sebastian


More information about the TYPO3-project-typo3v4mvc mailing list