【发布时间】:2014-06-05 19:44:55
【问题描述】:
我正在尝试使用 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,我无法弄清楚如何使用子查询或联合子查询进行查询。这个功能有什么帮助吗?谢谢!
【问题讨论】:
-
我对 Doctrine 没有任何经验,但是您是否尝试过将
as大写为AS?
标签: php mysql symfony zend-framework doctrine-orm