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


PHP Role::tableName方法代碼示例

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


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

示例1: search

 public function search($params)
 {
     $query = User::find()->joinWith(['role' => function ($query) {
         $query->from(['role' => Role::tableName()]);
     }]);
     if ($this->load($params) && $this->validate()) {
         $query->andFilterWhere(['id' => $this->id])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'role.item_name', $this['role.item_name']]);
         if (preg_match('/[\\d]{2}-[\\d]{2}-[\\d]{4}/', $this->created_at)) {
             $query->andFilterWhere(['AND', ['>', 'user.created_at', \DateTime::createFromFormat('d-m-Y H:i:s', $this->created_at . ' 00:00:00')->getTimestamp()], ['<', 'user.created_at', \DateTime::createFromFormat('d-m-Y H:i:s', $this->created_at . ' 23:59:59')->getTimestamp()]]);
         }
     }
     $userProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['attributes' => ['id', 'email', 'name', 'created_at' => ['asc' => ['user.created_at' => SORT_ASC], 'desc' => ['user.created_at' => SORT_DESC], 'default' => SORT_DESC], 'role.item_name'], 'defaultOrder' => ['created_at' => SORT_DESC]], 'pagination' => ['pageSize' => 10, 'defaultPageSize' => 10]]);
     return $userProvider;
 }
開發者ID:Sywooch,項目名稱:notes,代碼行數:14,代碼來源:UserSearch.php

示例2: actionUpdate

 public function actionUpdate($id)
 {
     $model = Notice::findOne($id);
     if ($model->load(Yii::$app->request->post())) {
         // 獲取用戶輸入的數據,驗證並保存
         $rids = $model->rids;
         $model->rids = ',' . implode(',', $model->rids) . ',';
         if ($model->save()) {
             $this->redirect('/notice/index');
         }
     }
     $rids = $model->rids;
     $model->rids = explode(',', $rids);
     $roles = Role::findBySql('SELECT * FROM ' . Role::tableName() . ' where id > 1')->all();
     return $this->render('update', array('model' => $model, 'roles' => $roles));
 }
開發者ID:vilison,項目名稱:yii2-order,代碼行數:16,代碼來源:NoticeController.php

示例3: actionUpdate

 public function actionUpdate($id)
 {
     $model = User::findOne($id);
     if (empty($model)) {
         throw new HttpException(404, '用戶不存在!');
     }
     if ($this->user->rid > 1 && $model->rid == 2) {
         throw new MethodNotAllowedHttpException('權限不夠!');
     }
     if ($model->load(Yii::$app->request->post())) {
         // 獲取用戶輸入的數據,驗證並保存
         if ($model->save()) {
             $this->redirect('/user/index');
         }
     }
     $roles = Role::findBySql('SELECT * FROM ' . Role::tableName() . ' where id > 1')->all();
     return $this->renderAjax('update', array('model' => $model, 'roles' => $roles));
 }
開發者ID:vilison,項目名稱:yii2-order,代碼行數:18,代碼來源:UserController.php


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