Subquery's with limit in Doctrine/Symfony using DQL -


i know how can set limit on 1 query , query based on selected results.

for example want select last 100 posts , operation.

$first_query= $this->getentitymanager()     ->createquery(         'select p testbundle:post p  order p.date desc'         )     ->setmaxresults(5);  

how use result select in next query?

 return $this->getentitymanager()     ->createquery(         "select  u.username , max(p.date),d.points,l.name          $first_query         join p.location l join p.user u join u.deeds d         l.name = :location         group u.id         order d.points desc , p.date desc         "          )     ->setparameter('location' , $location)     ->getresult(); 

i found out dql doesn't support limits went native sql.

$stmt = $this->getentitymanager()->getconnection()->prepare($query);     $stmt->execute();     return $stmt->fetchall(); 

this way can whatever want $query varaible can set limits , everythign it's normal sql statement.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

how to prompt save As Box in Excel Interlop c# MVC 4 -

xslt 1.0 - How to access or retrieve mets content of an item from another item? -