public function actionToursCategory() { Yii::app()->page->title = "Лог по турам"; if ($this->beginCache("console_log_tours_category", array('duration' => 3600 * 12))) { $list = CatLogToursCountry::sql("SELECT log.count, c.name FROM cat_log_tours_category log, catalog_tours_category c WHERE log.date2='" . date("Y-m") . "' AND c.id = log.category_id ORDER BY log.count DESC"); $rows = ""; for ($i = 0; $i < sizeof($list); $i++) { if (!empty($rows)) { $rows .= ","; } $rows .= "['" . $list[$i]["name"] . "', " . $list[$i]["count"] . ", 0, '#3366cc' ]"; } $this->render("toursCategory", array("rows" => $rows)); $this->endCache(); } }
static function saveCatLogCountry($countryId) { // Сохронякем индивидуальный лог по странам $check = CatLogToursCountry::findByAttributes(array("country_id" => $countryId, "date2" => date("Y-m")), 0); if (sizeof($check) > 0) { $check[0]->count++; $check[0]->save(); } else { $check = new CatLogToursCountry(); $check->count = 1; $check->country_id = $countryId; $check->date2 = date("Y-m"); if (!$check->save()) { print_r($check->getErrors()); } } }