Esempio n. 1
0
 /**
  * @param Recipe_Database_Select $select
  * @param array $fields
  * @return Recipe_Model_Resource_Abstract
  */
 public function addL10nOverlay(Recipe_Database_Select $select, array $fields)
 {
     $relTableName = current($this->getMainTable()) . "_l10n";
     $primaryKey = $this->getPrimaryKey();
     $tableAlias = key($this->getMainTable());
     $on = "l10n.{$primaryKey} = {$tableAlias}.{$primaryKey} AND l10n.language_id = ?";
     $on = $this->getDb()->quoteInto($on, Core::getLang()->getOpt("languageid"));
     $select->join(array("l10n" => $relTableName), $on);
     $attributes = array();
     foreach ($fields as $field) {
         $expr = "IFNULL(l10n.{$field}, {$tableAlias}.{$field})";
         $attributes[$field] = new Recipe_Database_Expr($expr);
     }
     $select->attributes(array("{$tableAlias}.*", "l10n" => $attributes));
     return $this;
 }
Esempio n. 2
0
 /**
  * Loads all total units.
  *
  * @param integer $mode
  * @return Bengine_Game_Controller_Statistics
  */
 protected function loadTotalUnits($mode)
 {
     $select = new Recipe_Database_Select();
     $select->from(array("c" => "construction"));
     $select->attributes(array("c" => array("name"), "s" => array("total" => new Recipe_Database_Expr("SUM(s.quantity)"))));
     $select->join(array("s" => "unit2shipyard"), array("s" => "unitid", "c" => "buildingid"))->group(array("c" => "buildingid"))->where(array("c" => "mode"), $mode)->order(array("c" => "display_order"), "ASC")->order(array("c" => "buildingid"), "ASC");
     $result = $select->getStatement();
     foreach ($result->fetchAll() as $row) {
         $this->unitCount[$mode][$row["name"]] = $row["total"];
     }
     $result->closeCursor();
     return $this;
 }