Search code examples
phppropelsymfony-2.1

Propel, Add alias to select statement


I'm using propel master-dev with symfony 2.1. Is possible to write something like that ? Else how can I add an alias to the select statement.

    $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();

Solution

  • Resolved:

        $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();