当前位置: 首页>>代码示例>>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;未经允许,请勿转载。