當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Option::find方法代碼示例

本文整理匯總了PHP中common\models\Option::find方法的典型用法代碼示例。如果您正苦於以下問題:PHP Option::find方法的具體用法?PHP Option::find怎麽用?PHP Option::find使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在common\models\Option的用法示例。


在下文中一共展示了Option::find方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getOptions

 /**
  * 獲取網站配置數組
  * @return array
  */
 public static function getOptions()
 {
     if (self::$_options == null) {
         $options = \common\models\Option::find()->asArray()->all();
         self::$_options = yii\helpers\ArrayHelper::map($options, 'name', 'value');
     }
     return self::$_options;
 }
開發者ID:Penton,項目名稱:MoBlog,代碼行數:12,代碼來源:Option.php

示例2: search

 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = OptionModel::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'value', $this->value])->andFilterWhere(['like', 'label', $this->label])->andFilterWhere(['like', 'group', $this->group]);
     return $dataProvider;
 }
開發者ID:writesdown,項目名稱:app-cms,代碼行數:18,代碼來源:Option.php

示例3: search

 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = OptionModel::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'option_name', $this->option_name])->andFilterWhere(['like', 'option_value', $this->option_value])->andFilterWhere(['like', 'option_label', $this->option_label])->andFilterWhere(['like', 'option_group', $this->option_group]);
     return $dataProvider;
 }
開發者ID:tampaphp,項目名稱:app-cms,代碼行數:21,代碼來源:Option.php

示例4: getAll

 /**
  * @param null $template_id
  * @return array
  */
 public static function getAll($template_id = null)
 {
     $options = [];
     if ($template_id) {
         $model = Option::find()->where(['template_id' => $template_id])->all();
     } else {
         $model = Option::find()->all();
     }
     if ($model) {
         foreach ($model as $m) {
             $options[$m->id] = $m->name;
         }
     }
     return $options;
 }
開發者ID:darkffh,項目名稱:yii2-lowbase,代碼行數:19,代碼來源:Option.php

示例5: search

 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $this->scenario = 'search';
     $query = Option::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'template_id' => $this->template_id, 'multiple' => $this->multiple, 'require' => $this->require, 'type' => $this->type]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
開發者ID:darkffh,項目名稱:yii2-lowbase,代碼行數:22,代碼來源:OptionSearch.php

示例6: getOptions

 /**
  * @return array|\yii\db\ActiveRecord[]
  */
 public function getOptions()
 {
     $options = Option::find()->where(['template_id' => $this->template_id])->orderBy('id')->all();
     return $options;
 }
開發者ID:p0vidl0,項目名稱:yii2-lowbase,代碼行數:8,代碼來源:Document.php

示例7: findModelByGroup

 /**
  * Finds the Option models based on their group.
  * If the models are not found, a 404 HTTP exception will be thrown.
  *
  * @param string $id
  *
  * @return Option the loaded model
  * @throws NotFoundHttpException if the models cannot be found
  */
 protected function findModelByGroup($id)
 {
     if ($model = Option::find()->where(['option_group' => $id])->indexBy('option_name')->all()) {
         return $model;
     }
     throw new NotFoundHttpException(Yii::t('writesdown', 'The requested page does not exist.'));
 }
開發者ID:tampaphp,項目名稱:app-cms,代碼行數:16,代碼來源:SettingController.php

示例8: actionGroup

 /**
  * Render option page for specific group of option.
  * It will use group file if exist.
  *
  * @param string $id group name
  *
  * @return string|\yii\web\Response
  * @throws \yii\web\NotFoundHttpException
  */
 public function actionGroup($id)
 {
     $model = Option::find()->where(['option_group' => $id])->indexBy('option_name')->all();
     if ($options = Yii::$app->request->post('Option')) {
         foreach ($options as $option_name => $option) {
             Option::up($option_name, $option['option_value']);
         }
         Yii::$app->getSession()->setFlash('success', Yii::t('writesdown', 'Settings successfully saved.'));
         return $this->redirect(['group', 'id' => $id]);
     }
     if ($model) {
         if (is_file($viewFile = $this->getViewPath() . '/' . strtolower($id) . '.php')) {
             return $this->render(strtolower($id), ['model' => (object) $model, 'group' => $id]);
         } else {
             return $this->redirect(['index']);
         }
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
開發者ID:ochiem,項目名稱:app-cms,代碼行數:29,代碼來源:SettingController.php


注:本文中的common\models\Option::find方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。