当前位置: 首页>>代码示例>>PHP>>正文


PHP User::tableName方法代码示例

本文整理汇总了PHP中app\models\User::tableName方法的典型用法代码示例。如果您正苦于以下问题:PHP User::tableName方法的具体用法?PHP User::tableName怎么用?PHP User::tableName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\User的用法示例。


在下文中一共展示了User::tableName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: search

 public function search($params, $whereParams = null)
 {
     $query = Note::find()->joinWith(User::tableName());
     $isAdminPanel = $this->getScenario() === 'admin';
     if ($whereParams) {
         $query->where($whereParams);
     }
     if ($this->load($params) && $this->validate()) {
         $query->andFilterWhere(['like', 'note.name', $this->name])->andFilterWhere(['like', 'user.name', $this['user.name']]);
         if ($isAdminPanel) {
             $query->andFilterWhere(['note.id' => $this->id])->andFilterWhere(['visibility' => $this->visibility]);
             if (preg_match('/[\\d]{2}-[\\d]{2}-[\\d]{4}/', $this->created_at)) {
                 $query->andFilterWhere(['AND', ['>', 'note.created_at', \DateTime::createFromFormat('d-m-Y H:i:s', $this->created_at . ' 00:00:00')->getTimestamp()], ['<', 'note.created_at', \DateTime::createFromFormat('d-m-Y H:i:s', $this->created_at . ' 23:59:59')->getTimestamp()]]);
             }
         } else {
             $query->andFilterWhere(['like', 'description', $this->description]);
         }
     }
     $noteSortAttributes = ['name' => ['asc' => ['note.name' => SORT_ASC], 'desc' => ['note.name' => SORT_DESC], 'label' => $this->getAttributeLabel('name')], 'created_at' => ['default' => SORT_DESC, 'label' => $this->getAttributeLabel('created_at')]];
     if ($isAdminPanel) {
         array_push($noteSortAttributes, 'id', 'user.name', 'visibility');
     } else {
         $noteSortAttributes['description'] = ['label' => $this->getAttributeLabel('description')];
     }
     $noteProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['attributes' => $noteSortAttributes, 'defaultOrder' => ['created_at' => SORT_DESC]], 'pagination' => ['pageSize' => $isAdminPanel ? 10 : 9, 'defaultPageSize' => $isAdminPanel ? 10 : 9]]);
     return $noteProvider;
 }
开发者ID:Sywooch,项目名称:notes,代码行数:27,代码来源:NoteSearch.php

示例2: behaviors

 public function behaviors()
 {
     return ['access' => ['class' => AccessControl::className(), 'only' => ['index', 'view', 'create', 'update', 'delete'], 'rules' => [['actions' => ['index', 'view', 'create', 'update', 'delete'], 'allow' => true, 'roles' => ['@']]]], 'verbs' => ['class' => VerbFilter::className(), 'actions' => ['delete' => ['post'], 'send-message' => ['post']]], ['class' => 'yii\\filters\\HttpCache', 'only' => ['index'], 'lastModified' => function ($action, $params) {
         $q = new Query();
         $res = $q->from(User::tableName())->max('create_date');
         return strtotime($res);
     }]];
 }
开发者ID:abutouq,项目名称:video,代码行数:8,代码来源:UsersController.php

示例3: meAndMyFriends

 /**
  * Find by my ID and my friends.
  *
  * @param $id
  * @return $this
  */
 public function meAndMyFriends($id)
 {
     $modelClass = $this->modelClass;
     $statusTableName = $modelClass::tableName();
     $relationTableName = Relation::tableName();
     $userTableName = User::tableName();
     return $this->innerJoin(Relation::tableName(), $relationTableName . '.following_id = ' . $statusTableName . '.author_id OR ' . $relationTableName . '.follower_id = ' . $statusTableName . '.author_id')->innerJoin(User::tableName(), $relationTableName . '.following_id = ' . $userTableName . '.id OR ' . $relationTableName . '.follower_id = ' . $userTableName . '.id')->andWhere([User::tableName() . '.id' => $id])->orderBy($statusTableName . '.created_at DESC');
 }
开发者ID:artpro676,项目名称:twitter,代码行数:14,代码来源:StatusQuery.php

示例4: up

 public function up()
 {
     $this->alterColumn(User::tableName(), 'role', 'smallint(6) NOT NULL DEFAULT 1');
     $this->alterColumn(User::tableName(), 'status', 'smallint(6) NOT NULL DEFAULT 1');
     $this->update(User::tableName(), ['status' => User::STATUS_ADMIN_ACTIVE], 'status = 10 and role = 1');
     $this->update(User::tableName(), ['status' => User::STATUS_ACTIVE], 'status = 0 or (status = 10 and role > 1)');
     $this->update(User::tableName(), ['role' => 3], 'role=1');
     $this->update(User::tableName(), ['role' => User::ROLE_DEV], 'role=2');
     $this->update(User::tableName(), ['role' => User::ROLE_ADMIN], 'role=3');
 }
开发者ID:ashehui,项目名称:walle-web,代码行数:10,代码来源:m160418_035413_user_status_migrate.php

示例5: getQuery

 /**
  * @param array $params
  * @param bool $filterByUser
  * @return \yii\db\Query
  */
 public static function getQuery($params = [], $filterByUser = true)
 {
     $portionCaloriesSql = self::getPortionCaloriesQuery('`d`.`id`')->createCommand()->sql;
     $recipeCaloriesSql = self::getRecipeCaloriesQuery('`d`.`id`')->createCommand()->sql;
     $productCaloriesSql = self::getProductCaloriesQuery('`d`.`id`')->createCommand()->sql;
     $portWeightSql = self::getPortionsWeightQuery('`d`.`id`')->createCommand()->sql;
     $recWeightSql = self::getRecipesWeightQuery('`d`.`id`')->createCommand()->sql;
     $prodWeightSql = self::getProductsWeightQuery('`d`.`id`')->createCommand()->sql;
     $query = Diary::find()->select(['`d`.*', '`u`.`weighing_day` AS `weighingDay`', "COALESCE(({$portionCaloriesSql}), 0) + COALESCE(({$recipeCaloriesSql}), 0) + COALESCE(({$productCaloriesSql}), 0) AS `calories`", "COALESCE(({$prodWeightSql}), 0) + COALESCE(({$recWeightSql}), 0) + COALESCE(({$portWeightSql}), 0) AS `weight`"])->from(self::tableName() . ' `d`')->leftJoin(User::tableName() . ' `u`', '`u`.`id` = `d`.`user_id`');
     if ($filterByUser) {
         $query->where(['`d`.`user_id`' => Yii::$app->user->id]);
     }
     return $query;
 }
开发者ID:remk-wadriga,项目名称:calories-calculating-yii2-project,代码行数:19,代码来源:DiaryRepository.php

示例6: run

 function run()
 {
     // && $model->contact(Yii::$app->params['adminEmail'])
     $this->enable_form = $this->allow_comments();
     $comment = new Comments();
     $comment->parent_id = 0;
     if ($this->enable_form && $comment->load(Yii::$app->request->post()) && $comment->validate()) {
         Yii::$app->session->setFlash('commentFormSubmitted');
         $comment->active = true;
         $comment->user_id = Yii::$app->user->isGuest ? null : Yii::$app->user->identity->id;
         $comment->ip = ip2long(Yii::$app->request->getUserIP());
         $comment->agent = Yii::$app->request->getUserAgent();
         $comment->saveUploadedImage('file');
         $comment->save();
         return Yii::$app->getResponse()->redirect(Yii::$app->getRequest()->getUrl());
     }
     $query = new Query();
     $query->addSelect('c.*, f.filename, f.thumb_filename, f.size, u.username')->from([Comments::tableName() . ' c'])->leftJoin(User::tableName() . ' u', 'u.id = c.user_id')->leftJoin(Files::tableName() . ' f', 'f.id = c.image_id')->where(['c.active' => true])->andWhere(['c.post_id' => $this->post_id]);
     $comment->post_id = $this->post_id;
     return $this->render('comments/comments_box', ['comments' => $this->buildTree($query->all()), 'model' => $comment, 'enable' => $this->enable_form]);
 }
开发者ID:hysdop,项目名称:YobaCMS,代码行数:21,代码来源:CommentsWidget.php

示例7: actionIndex

 /**
  * Все
  *
  * @param null $q
  * @param null $id
  * @return array
  */
 public function actionIndex($q = null, $id = null)
 {
     Yii::$app->response->format = Response::FORMAT_JSON;
     $out = ['results' => ['id' => '', 'text' => '']];
     if (!is_null($q)) {
         $query = new Query();
         $query->select('id, name, surname')->from(User::tableName())->where(['like', 'name', $q])->orWhere(['like', 'surname', $q])->limit(20);
         $command = $query->createCommand();
         $data = $command->queryAll();
         $users = [];
         foreach ($data as &$user) {
             $users[] = ['id' => $user['id'], 'text' => $user['name'] . ' ' . $user['surname']];
         }
         $out['results'] = $users;
     } else {
         if ($id > 0) {
             $user = User::findIdentity($id);
             if ($user) {
                 $out['results'] = ['id' => $user->id, 'text' => $user->name . ' ' . $user->surname];
             }
         }
     }
     return $out;
 }
开发者ID:nepster-web,项目名称:yii2-test-job,代码行数:31,代码来源:UserController.php

示例8: actionIndex

 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => User::findBySql('select * from ' . User::tableName() . ' where isadmin = 0'), 'pagination' => ['pagesize' => '20']]);
     return $this->render('index', array('dataProvider' => $dataProvider));
 }
开发者ID:vilison,项目名称:yii2-order,代码行数:5,代码来源:UserController.php

示例9: down

 public function down()
 {
     $this->dropTable('group');
     $this->dropColumn(\app\models\User::tableName(), 'avatar');
     return true;
 }
开发者ID:9618211,项目名称:walle-web,代码行数:6,代码来源:m150929_115951_project_user_group.php

示例10: down

 public function down()
 {
     $this->dropColumn(User::tableName(), 'options');
 }
开发者ID:JohnRivers,项目名称:seed-testing,代码行数:4,代码来源:m160101_154734_add_options_to_users.php

示例11: down

 public function down()
 {
     $this->dropTable(User::tableName());
 }
开发者ID:skoro,项目名称:yii2-admin-template,代码行数:4,代码来源:m160314_212231_user.php

示例12: testTableName

 public function testTableName()
 {
     $this->assertEquals('user', User::tableName());
 }
开发者ID:snedi,项目名称:book-management,代码行数:4,代码来源:UserTest.php

示例13: getReceiver

 /**
  * @return \yii\db\ActiveQuery
  */
 public function getReceiver()
 {
     return $this->hasOne(User::className(), ['id' => 'receiver_id'])->from(User::tableName() . ' receiver');
 }
开发者ID:abutouq,项目名称:video,代码行数:7,代码来源:Message.php

示例14: down

 public function down()
 {
     echo "m150926_151034_init_user reverted.\n";
     $this->delete(User::tableName(), ['id' => [1, 2]]);
     return true;
 }
开发者ID:9618211,项目名称:walle-web,代码行数:6,代码来源:m150926_151034_init_user.php

示例15: getCalendarEvents

 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCalendarEvents()
 {
     return $this->hasMany(CalendarEvent::className(), ['calendar_id' => 'calendar_id'])->viaTable(User::tableName(), ['id' => 'user_id']);
 }
开发者ID:afernandes465,项目名称:memoboard,代码行数:7,代码来源:FamilyMember.php


注:本文中的app\models\User::tableName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。