我有以下查询:
$latestcontent = $em->createQuery('
SELECT c.title, c.content, c.lastedit, a.firstname, a.surname
FROM ShoutMainBundle:Content c, ShoutMainBundle:Admin a
WHERE c.author = a.id
ORDER BY c.lastedit ASC'
);
我需要做的是限制从这个查询返回的记录数量。然而,当我在SQL查询中添加LIMIT 10时,它会返回以下错误:
错误:期望字符串结束,得到'LIMIT'。
所以,我研究后发现可以在查询之后添加->limit(10)
。但这样会引发以下PHP错误:
Fatal error: Call to undefined method Doctrine\ORM\Query::limit() in C:\wamp\www\src\Shout\AdminBundle\Controller\DefaultController.php on line 22
我做错了什么?