[FLOW3-general] Using DQL

Regine Rosewich regine.rosewich at hoellenberg.biz
Tue Nov 22 15:07:38 CET 2011


Hi Pankaj,

as an old "MySqler" I'm much more familiar with DQL than with the
queryManager of FLOW3. So I do work but with DQL in my Repositories.
As you can see from the following example, it is no Problem to get a
TYPO3\FLOW3\Persistence\QueryResultInterface back from a DQL query.

	/**
	 * Searches the product-groups of a certain product-class with the
object for the product-class
	 * 
	 * @param \De\Welu\WeluPdm\Domain\Model\Klassifizierung\Klasse
$klasse the product-class
	 * @return \TYPO3\FLOW3\Persistence\QueryResultProxy the
product-groups returned
 	 */
	public function
findGruppenByKlasseObject(\De\Welu\WeluPdm\Domain\Model\Klassifizierung\Klas
se $klasse) {
		return $this->entityManager
			->createQuery('SELECT g FROM
\De\Welu\WeluPdm\Domain\Model\Klassifizierung\Gruppe g WHERE g.klasse =
:klasse ORDER BY g.anzeigeFolge ASC')
			->setParameter('klasse', $klasse)
			->execute();
	}

Btw. DQL queries are really fast and can be extremely complex (if
necessary).

Hope it helps.

Regine
> -----Ursprüngliche Nachricht-----
> Von: flow3-general-bounces at lists.typo3.org [mailto:flow3-general-
> bounces at lists.typo3.org] Im Auftrag von Pankaj Lele
> Gesendet: Dienstag, 22. November 2011 13:07
> An: flow3-general at lists.typo3.org
> Betreff: [FLOW3-general] Using DQL
> 
> Hello!
> 
> I want to use DQL inside my package for some complex queries.
> 
> What I have figured out for using DQL I just need to:
> 
> 1. Change my repository class to extend
> \TYPO3\FLOW3\Persistence\Doctrine\Repository instead of
> \TYPO3\FLOW3\Persistence\Repository
> 
> 2. Write my query with $this->entityManager->createQuery('SELECT x ...
> DQL query ');
> 
> Is this is a standard and futuristic way?
> 
> I tried switching the repository base class to
> \TYPO3\FLOW3\Persistence\Doctrine\Repository for one of my repositories
> and the paginate widget failed as it was expecting an
> TYPO3\FLOW3\Persistence\QueryResultInterface
> 
> Is it possible to have the repository class extends
> \TYPO3\FLOW3\Persistence\Repository and still use DQL somehow?
> 
> Or
> 
> Is it ok to have another repository class only for special DQL queries
> where I am aware of special features won't work like paginate or
> content
> security at the moment?
> 
> Thanks in advance.
> 
> 
> --
> 
> With best regards,
> Pankaj Lele
> ---------------------------
> 
> CTO & Executive Director
> Lelesys Infotech Pvt. Ltd.
> Pune/Goa, India
> 
> Web: http://www.lelesys.com
> 
> [Certified TYPO3 Integrator]
> _______________________________________________
> FLOW3-general mailing list
> FLOW3-general at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow3-general




More information about the FLOW3-general mailing list