开发者

query builder select the id from leftJoin

I have a select field that fetch from an entity and I would like to customize completely my select by choosing the table the id is picked from (here I would like to select t.id instead of tl.id as开发者_如何学JAVA the select value)

return $er->createQueryBuilder('tl')
    ->addSelect('l')
    ->addSelect('t')
    ->leftJoin('tl.lang', 'l')
    ->leftJoin('tl.type', 't')
    ->where('l.isDefault = 1')
    ->orderBy('tl.name', 'ASC');

Due to my tables, I can't simply fetch the table t, I have to use tl


Your query is not according to the syntax defined in Doctrine 2 QueryBuilder: http://www.doctrine-project.org/docs/orm/2.0/en/reference/query-builder.html

Your query might work in Doctrine 1.2 but in Doctrine 2 you should build your query according to the syntax defined in the link I posted above.

For example ->addSelect('l') is not being used in Doctrine 2 anymore. It has become ->add('select', 'l').


You don't have to set different alias for your column. It'll be hydrated as column of the related entity.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜