1k visitas
Custom querys in symfony with the setListQuery method
->For use with Symfony Framework<-
This code shows how to change the auto generated symfony query used when we call $this->getRoute()->getObject() for another created by yourself.
In the following example we will create a query with two left joins and a where condition.
PHP
- //First step is create the custom query
- $q = Doctrine_Query::create()
- ->from('Table r')->leftJoin('r.table2')->leftJoin('r.table3')->addWhere('Name= ?',$request->getParameter('name_slug'));
- //Then we call setListQuery with the query
- $this->getRoute()->setListQuery($q);
- //Last we get the object as usual
- $this->ranking = $this->getRoute()->getObject();
Enviado por jdtuero hace over 2 years — modificado por última vez hace less than a minute