Documentation » Doctrine2 ORM Admin

11. Troubleshooting »

« 9. Audit

10. Doctrine ORM Proxy Query

The ProxyQuery object is used to add missing features from the original Doctrine Query builder :

  • execute method - no need to call the getQuery() method
  • add sort by and sort order options
  • add preselect id query on left join query, so a limit query will be only applied on the left statement and not on the full select statement. This simulates the original Doctrine 1 behavior.
use Sonata\AdminBundle\Datagrid\ORM\ProxyQuery;

$queryBuilder = $this->em->createQueryBuilder();
$queryBuilder->from('Post', 'p');

$proxyQuery = new ProxyQuery($queryBuilder);
$proxyQuery->leftJoin('p.tags', 't');

$results = $proxyQuery->execute();

Found a typo? Something is wrong in this documentation? Just fork and edit it!