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

Jan-Erik Revsbech janerik at mocsystems.com
Fri Dec 18 17:09:07 CET 2009


> 
> > 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_DocumentRe
> posit
> > ory');
> 
> > $Query = $this->documentRepository->createQuery();
> Does this work? I thought createQuery() was protected, and not public.
> Definitely it should be protected.

Yes, and it's in the Blogexample. But it makes sence to put it into my
repository.

> 
> 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 :)
> 

Thanks, that will probably work, but I rather find the "extbase way":)

Thanks a lot
Jan-Erik



More information about the TYPO3-project-typo3v4mvc mailing list