mysql - Doctrine LIMIT 语法错误?

标签 mysql doctrine

'[Syntax Error] line 0, col 71: Error: Expected end of string, got 'LIMIT'' 

这是我的代码:

public function getLatestChapters()
    {
        return $this->_em->createQuery('SELECT c, m FROM models\Chapter c JOIN c.Manga m ORDER BY c.CreateDate LIMIT 10')->getResult();
    }

这可能是什么问题?如何在 Doctrine 中使用 LIMIT?

我正在使用 Doctrine 2

最佳答案

好像有no DQL anymore 中的限制/偏移.

$qb = $em->createQueryBuilder();
//.. build your query
$q = $qb->getQuery();
$q->setFirstResult($offset);
$q->setMaxResults($limit);
$result = $q->getResult(); 

关于mysql - Doctrine LIMIT 语法错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6635601/

相关文章:

mysql - Hibernate createSQLQuery - 它如何验证 SQL?

php - 如何将 andWhere 和 orWhere 与 Doctrines Criteria 结合起来

php - mySQL 数据库 - 每 15 分钟将某些列重置为 '0'

php - 如何从Firebird数据库读取数据并将数据插入MSSQL数据库?

mysql - SQL:如何用一个id引用多个数据集?

php - Symfony 2/Doctrine : How to lower the num of queries without losing the benefit of ORM?

php - 当pgsql通过PDO连接时,如何使用pg_get_pid函数?

mysql - 使用查询的结果,例如另一个 table_name

mysql - Have 字段 Doctrine 中的子查询

php - 给定数据库建模的 Symfony + Doctrine 问题