If statement 如何使用DoctrineExtensions提供的IF语句

If statement 如何使用DoctrineExtensions提供的IF语句,if-statement,doctrine,doctrine-orm,If Statement,Doctrine,Doctrine Orm,我在玩,但没办法。在注册DoctrineExtensions之后,我使用Zend Framework创建了以下DQL行: $qb->having(new IfElse("A.type = 0", new FindInSet(1, new GroupConcat('B.id', ',')) >0 , '1') ); 但是得到这个错误消息: 例外信息: 消息:“DoctrineExtensions\Query\Mysql\IfElse”类型的表达式 在这种情况下是不允许的* 您能帮我指

我在玩,但没办法。在注册DoctrineExtensions之后,我使用Zend Framework创建了以下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列:错误:预期的条令\ORM\Query\Lexer::T_逗号,得到“=”

也许我的语法错了?

你试过了吗

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

我回来晚了,在这里给面临同样问题的人留下评论。这比原来的问题要复杂一点,但我的问题是:$qb->having(“如果($qb->expr()->neq($s.userId)”,$arrCondition['current\u user']),如果($arrCondition['current\u user']),如果($arrCondition['current\u user']),如果(I.type>1),如果(I.type=0,GROUP\u CONCAT(I.receiver),GROUP\u CONCAT(I.createdBy)))>=0,即状态,0),1)=1”);