我正在尝试使用Doctrine进行具有子查询的查询。目前它给了我一个错误。我的存储库中的函数是:
public function getRecentPlaylists($count = 3) {
$q = $this->_em->createQuery("
SELECT p.id,
p.featuredImage,
p.title,
p.slug,
a.firstName,
a.lastName,
a.slug as authorSlug,
(SELECT updated
FROM \Entities\Articles
ORDER BY updated DESC LIMIT 1) as updated
FROM \Entities\Playlist p
JOIN \Entities\Account a
ON p.account_id = a.id
")
->setMaxResults($count);
try{
return $q->getResult();
}catch(Exception $e){
echo $e->message();
}
}
这给我带来了这个错误:
[Semantical Error] line 0, col 210 near 'LIMIT 1) as updated FROM': Error: Class 'LIMIT' is not defined.
我几乎放弃了Doctrine,我一直无法弄清楚如何使用子查询或带有子查询的联合查询。有关此功能的任何帮助?谢谢!
as
改为大写的AS
吗? - Brobin