Example #1
0
 public function checkExist()
 {
     if ($this->isNewRecord || $this->id != $this->oldAttributes['id']) {
         $ret = Variable::findOne($this->id);
         return $ret !== null;
     }
     return false;
 }
 protected function findModel($id)
 {
     if (($model = Variable::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #3
0
 public function search($params)
 {
     $query = VariableModel::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['data_type' => $this->data_type, 'is_cache' => $this->is_cache, 'sort_num' => $this->sort_num]);
     $query->andFilterWhere(['like', 'variable', $this->variable])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'value', $this->value])->andFilterWhere(['like', 'description', $this->description]);
     return $dataProvider;
 }
Example #4
0
 public static function createVariableCache()
 {
     self::createCacheFile();
     $content = '<?php' . self::$newLine;
     $dataList = Variable::findAll();
     foreach ($dataList as $row) {
         $id = $row['id'];
         $content .= '$cachedVariables[\'' . $row['id'] . '\']=[' . self::$newLine;
         $content .= self::getCacheItem('id', $row);
         $content .= self::getCacheItem('name', $row);
         $content .= self::getCacheItem('value', $row);
         $content .= self::getCacheItem('data_type', $row, 'int');
         $content .= self::getCacheItem('is_cache', $row, 'bool');
         $content .= self::getCacheItem('note', $row);
         $content .= "];" . self::$newLine;
     }
     self::writeFile('cachedVariables.php', $content);
 }