¿Eres nuevo? ¡Lee el FAQ y ponte al día!
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
  1. //First step is create the custom query
  2. $q = Doctrine_Query::create()
  3.         ->from('Table r')->leftJoin('r.table2')->leftJoin('r.table3')->addWhere('Name= ?',$request->getParameter('name_slug'));
  4. //Then we call setListQuery with the query
  5. $this->getRoute()->setListQuery($q);
  6. //Last we get the object as usual
  7. $this->ranking = $this->getRoute()->getObject();
  8.  

­

Etiquetas: PHP sql setListQuery symfony

Insertar: