0
public function mpttLocationList() {
        $q = $this->_em->createQuery("
        SELECT CONCAT(REPEAT('.', COUNT(parent.region_name) - 1), node.region_name) AS name
        FROM ViveListingBundle:region_redefine AS node,
                ViveListingBundle:region_redefine AS parent
        WHERE node.lft BETWEEN parent.lft AND parent.rgt
        GROUP BY node.region_name
        ORDER BY node.lft");
        return $q->getResult();
    } 

上面的代码给出了错误:

[Syntax Error] line 0, col 23: Error: Expected known function, got 'REPEAT'.
4

2 回答 2

0

REPEAT不是有效的 DQL 函数。请记住,DQL 不是 SQL,它看起来很相似,但有重要区别,并且不支持所有 SQL 结构。查看 DQL 文档以了解支持的内容:

http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/dql-doctrine-query-language.html

于 2012-10-07T13:25:03.063 回答
0

To teach Doctrine about REPEAT(), you need to define a custom DQL function and register it with Symfony.

于 2012-10-08T06:51:49.667 回答