示例#1
0
 /**
  * This method returns all the keys of the global settings in an array. 
  * Returns an array of keys if found.
  * Returns false if no keys.
  * 
  * @return array | boolean
  */
 public static function getKeys()
 {
     $dependency = new CDbCacheDependency('SELECT MAX(updated_time) FROM global_settings');
     $criteria = new CDbCriteria();
     $criteria->select = 'label';
     $models = GlobalSettings::model()->cache(1000, $dependency)->findAll($criteria);
     if ($models) {
         $result = array();
         foreach ($models as $model) {
             $result[] = $model->label;
         }
         return $result;
     } else {
         return false;
     }
 }
 /**
  * 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 the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = GlobalSettings::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }