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
Post a Comment