2012-06-19 44 views
5

我正在使用symfony 2.1推进master-dev。 可以写这样的东西吗?否则,我该如何添加一个别名到select语句。Propel,添加别名以选择语句

$products = ProdottinewQuery::create() 
     ->leftJoinWith('Prodotticolori') 
     ->leftJoinWith('Alberocategorie') 
     ->leftJoinWith('Brand') 
     ->leftJoinWith('Prodottimateriali') 
     ->leftJoinWith('Prodottigroffatura') 
     ->select(array('id', 
        'codice', 
        'nomeEng', 
        'Alberocategorie.nomeeng' => 'category', 
        'Prodotticolori.coloreeng' => 'color', 
        'Brand.brand' => 'brand', 
        'Prodottimateriali.materialeeng' => 'material', 
        'Prodottigroffatura.groffaturaeng' => 'groffage')) 
     ->orderById() 
     ->limit($howmany) 
     ->find(); 

回答

9

解决:

$products = ProdottinewQuery::create() 
     ->leftJoinWith('Prodotticolori') 
     ->leftJoinWith('Alberocategorie') 
     ->leftJoinWith('Brand') 
     ->leftJoinWith('Prodottimateriali') 
     ->leftJoinWith('Prodottigroffatura') 
     ->select(array('id', 
        'codice', 
        'nomeEng')) 
     ->withColumn('Alberocategorie.nomeeng', 'category') 
     ->withColumn('Prodotticolori.coloreeng', 'color') 
     ->withColumn('Brand.brand', 'brand') 
     ->withColumn('Prodottimateriali.materialeeng', 'material') 
     ->withColumn('Prodottigroffatura.groffaturaeng', 'groffage') 
     ->orderById() 
     ->limit($howmany) 
     ->find();