Want more features on Pastebin? Sign Up, it's FREE!
Guest

zf2 db bug

By: a guest on Sep 5th, 2012  |  syntax: PHP  |  size: 1.86 KB  |  views: 44  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.         $select = $this->getDrinkTable()->newSelect();
  2.         $this->getDrinkTable()->getSelect($select)
  3.         ->join('drink_type','drink.drink_type_id = drink_type.drink_type_id',array())
  4.         ->join('drink_brand','drink_brand.drink_brand_id = drink_brand.drink_brand_id',array())
  5.         ->join('drink_company','drink_company.drink_company_id = drink_brand.drink_company_id',array())
  6.         ->join('drink_flavor','drink_flavor.drink_id = drink.drink_id',array('calories_for_100g'))
  7.         ->join('drink_ingredient','drink_ingredient.drink_flavor_id = drink_flavor.drink_flavor_id',array())
  8.         ->join('drink_flavor_type','drink_flavor.drink_flavor_type_id = drink_flavor_type.drink_flavor_type_id',array('drink_flavor_type_name'))
  9.                 ->join('drink_ingredient_type','drink_ingredient_type.drink_ingredient_type_id = drink_ingredient.drink_ingredient_type_id',array('drink_ingredients'=>new \Zend\Db\Sql\Expression('GROUP_CONCAT(drink_ingredient_type_name)')))
  10.         ->join('liquid_color','liquid_color.liquid_color_id = drink_flavor.liquid_color_id',array('is_transparent'))
  11.         ->join('liquid_color_type','liquid_color_type.liquid_color_type_id = liquid_color.liquid_color_type_id',array('liquid_color_type_name'))
  12.         ->join('alcohol_sum','alcohol_sum.alcohol_sum_id = drink_flavor.alcohol_sum_id',array('alcohol_by_volume'))
  13.         ->where
  14.         ->equalTo('drink_flavor_type.drink_flavor_type_name',$drinkFlavor)
  15.         ->equalTo('drink_company.drink_company_name',$drinkCompany)
  16.         ->equalTo('drink_brand.drink_brand_name',$drinkBrand)
  17.         ->equalTo('drink_type.drink_type_name',$drinkType);
  18.         $resultSet=$this->getDrinkTable()->selectWith($select);
  19.         $result="";
  20.         if ($resultSet->count()>0) {
  21.                 $rows=$resultSet->toArray();
  22.                 if (count($rows) > 1 || $rows[0]['liquid_color_type_name'] != null ) { //overcome zf bug
  23.                         $result=json_encode($rows[0]);
  24.                 }
  25.         }
clone this paste RAW Paste Data