开发者

Doctrine 2 join troubles

开发者 https://www.devze.com 2023-01-17 07:29 出处:网络
I try to do this query using doctrine query builder $idAccount = $params[\'idAccount\']; $qb = $this->_em->createQueryBuilder()->select(\'t,tt\')

I try to do this query using doctrine query builder

$idAccount = $params['idAccount'];
$qb = $this->_em->createQueryBuilder()->select('t,tt')
                ->from($this->_entityName, 'sr')
                ->innerJoin('sr.account', 'a')
                ->innerJoin('sr.product', 'p')
                ->leftJoin('p.title', 't')
                ->leftJoin('p.set', 's')
                ->leftJoin('s.idTitle', 'tt');
开发者_运维技巧        $qb->where($qb->expr()->eq('a.idAccount',$idAccount));

end have this error:

E_WARNING

class_parents() [function.class-parents]: object or string expected D:\Doctrine\ORM\Mapping\ClassMetadataFactory.php : 224

but when I fetch select('sr,a,p,s,t,tt') with this criteria all works fine. and when i use HYDRATE_ARRAY hydration all works fine too. But I need only t and tt fields, is there any way to do this??


For object hydration you have to fetch the element set in FROM clause currently. There might even be an open bug/enhancement report for this.

0

精彩评论

暂无评论...
验证码 换一张
取 消