Пример #1
0
 public function getGuino()
 {
     $ya = date('Y-m-d H:i:s');
     $c = new CDbCriteria();
     $c->condition = 'estado = :estado AND (inicio_publicacion < :inicio_p OR inicio_publicacion IS NULL) AND (fin_publicacion > :fin_p OR fin_publicacion IS NULL)';
     $c->params = array(':estado' => 1, 'inicio_p' => $ya, 'fin_p' => $ya);
     $dependencia = new CDbCacheDependency("SELECT GREATEST(MAX(creado), MAX(modificado)) FROM guino WHERE estado = 1 AND (inicio_publicacion < '" . $ya . "' OR inicio_publicacion IS NULL) AND (fin_publicacion > '" . $ya . "' OR fin_publicacion IS NULL)");
     return Guino::model()->cache(3600, $dependencia)->find($c);
 }
Пример #2
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Url the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Guino::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }