symfony - Pagination with OrderBy and Jointure -
i've pagination problem annoying, here repository code:
public function listesujetsadmin($forum, $user, $page){ $builder = $this->createquerybuilder('s'); $builder ->andwhere($builder->expr()->eq('s.forum', ':forum')) ->setparameter("forum", $forum->getid()) ->addselect('c') ->leftjoin('s.commentaires', 'c') ->orderby('c.datecreation', 'desc') ->addselect('l') ->leftjoin('s.lectures', 'l', expr\join::with, $builder->expr()->eq('l.user', ':user')) ->setparameter('user', $user->getid()) ->setfirstresult( sujet::max_par_page * ($page-1) ) ->setmaxresults( sujet::max_par_page ); return new paginator($builder); }
if keep "->orderby('c.datecreation', 'desc')", doctrine considers every commentaires (c) has counted want count subjects (s).
this profiler shows here:
thanks !