我们如何在 Symfony 2 中使用教义执行这个查询:
SQL:
SELECT p.* FROM messages, (SELECT * from posts ORDER BY created_at DESC) as p GROUP BY p.category_id ORDER BY message.created_at;
问题:每个表都必须是像 MyProjectMyBundle:MyEntity 这样的实体,(SELECT * from posts ORDER BY created_at DESC)不是实体...
Symfony 2(不起作用):
$query = $em->createQuery('SELECT p.*
FROM MyProjectMyBundle:Messages,
(SELECT * from posts ORDER BY created_at DESC) as p
GROUP BY p.category_id ORDER BY message.createdAt');
我们可以包含其他查询,例如 Mysql 吗?一个办法?
谢谢