1

我正在玩DoctrineExtensions但无法管理它。注册 DoctrineExtensions 后,我在 Zend 框架中有以下 DQL 行:

$qb->having(new IfElse("A.type = 0", new FindInSet(1, new GroupConcat('B.id', ',')) >0 , '1') );

但是得到这个错误消息:

异常信息:

消息:在此上下文中不允许使用“DoctrineExtensions\Query\Mysql\IfElse”类型的表达式。*

您能帮我指出我的命令或有关如何使用 DoctrineExtensions 的任何文档中有什么不正确的地方吗?

更新:

我找到了一种通过以下方式实现自定义功能的方法:我通过将这一行添加到 boostrap 来尝试一下:

$config->addCustomStringFunction('IF', 'DoctrineExtensions\Query\Mysql\IfElse');

并在 DQL 中将其用作:

$qb->having("IF( A.type = 0, S.status = 0, S.status = 1 )");

但是得到这个错误:

消息:[语法错误] 第 0 行,第 152 列:错误:预期的 Doctrine\ORM\Query\Lexer::T_COMMA,得到 '='

也许我语法错误?

4

1 回答 1

0

你有没有尝试过

$qb->having("S.status = IF( A.type = 0, 0, 1 )");
于 2013-11-08T10:42:10.887 回答