mysql - ORDER BY Count(p.id) is it possible? -


i have following query:

$querybuilder = $em->createquerybuilder()->select('s')                 ->from("mainbundle:style", 's')                 ->select('distinct s')                 ->leftjoin('s.picturestyle', 'ps')                 ->leftjoin('ps.picture', 'p')                 ->leftjoin('p.category', 'pc');          if ($category instanceof instagramtopcategory)         {             $querybuilder->leftjoin('pc.picturetopcategory', 'category');         }         else if ($category instanceof instagramfirstlevelcategory)         {             $querybuilder->leftjoin('pc.picturefirstlevelcategory', 'category');         }         else if ($category instanceof instagramsecondlevelcategory)         {             $querybuilder->leftjoin('pc.picturesecondlevelcategory', 'category');         }          $query = $querybuilder->where('category = :category')                 ->andwhere('p.islocked = 0')                 ->andwhere('p.deletedat null')                 ->orderby('count(p.id)', 'desc')                 ->groupby('ps.picturestyle')                 ->setparameter('category', $category)                 ->setmaxresults(10)                 ->getquery(); 

however in order by, doesn't gives me error of:

 error: expected end of string, got '(' 

how possible? wrote equivalent query in mysql using count directly in orderby , worked fine, issue in doctrine?

edit: 100% sure it's order since if remove line error goes away

modify query follows

$querybuilder = $em->createquerybuilder()     ->select('s')     ->from("mainbundle:style", 's')     ->select('distinct s')     ->addselect('count(p.id) hidden c_id')    [...]     ->orderby('c_id', 'desc')    [...] 

Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -