2013-12-13 25 views
2

我使用Doctrine2和QueryBuilder。我需要有像表达式(ABB的\实体\表选择oneval)* sometable.amount /交换如何在QueryBuilder的addSelect中使用子查询进行乘法

$qb=$this->entityManager->createQueryBuilder(); 
$qb->addSelect('p.amount*(select crr.rateusd from 
Application\DBUtils\Entities\Currency 
where crr.code=c.currency)/25 as amountselected'); 

[语法错误] 0行,列241:错误:预期文字,得到了 '选择'

谢谢

+0

您是否找到合适的解决方案@Konstantin Vahrushev? – webDEVILopers

+0

@webDEVILopers 我不得不用join来替换子查询。因此,我有: ** $ qb-> addSelect('p.amount * curr.rateusd as amountselected') - > leftJoin('Application \ DBUtils \ Entities \ Currency','curr',\ Doctrine \ ORM \ Query \ Expr \ Join :: WITH,'c.currency = curr.code') \t - > leftJoin('Application \ DBUtils \ Entities \ Customer','c',\ Doctrine \ ORM \ Query \ Expr \加入:: WITH,'p.customerid = c.id'); ** –

回答

相关问题