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


PHP User::tableName方法代码示例

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


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

示例1: searchDeleted

 public function searchDeleted($params)
 {
     $dataProvider = $this->search();
     $dataProvider->query->where(['or', ['and', ['sender_id' => Yii::$app->user->id], ['sender_status' => Message::getDeletedStatuses()]], ['and', ['receiver_id' => Yii::$app->user->id], ['receiver_status' => Message::getDeletedStatuses()]]]);
     if (!($this->load($params) && $this->validate())) {
         $dataProvider->query->joinWith(['receiverUser' => function ($q) {
             $q->from(User::tableName() . ' pdu_receiver');
         }, 'senderUser' => function ($q) {
             $q->from(User::tableName() . ' pdu_sender');
         }]);
         return $dataProvider;
     }
     $dataProvider->query->andFilterWhere(['like', 'topic', $this->topic]);
     $dataProvider->query->joinWith(['receiverUser' => function ($q) {
         $q->from(User::tableName() . ' pdu_receiver')->where(['like', 'pdu_receiver.username', $this->receiverName]);
     }, 'senderUser' => function ($q) {
         $q->from(User::tableName() . ' pdu_sender')->where(['like', 'pdu_sender.username', $this->senderName]);
     }]);
     return $dataProvider;
 }
开发者ID:keltstr,项目名称:yii2-podium,代码行数:20,代码来源:MessageSearch.php

示例2: search

 /**
  * Searches for sent messages.
  * @param array $params
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     // not very proud of this query - slow for sure
     // let me know if it can be done better.
     $subquery = (new Query())->select(['m2.replyto'])->from(['m1' => Message::tableName()])->leftJoin(['m2' => Message::tableName()], '`m1`.`replyto` = `m2`.`id`')->where(['is not', 'm2.replyto', null]);
     $query = self::find()->where(['and', ['sender_id' => User::loggedId(), 'sender_status' => Message::getSentStatuses()], ['not in', Message::tableName() . '.id', $subquery]]);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['attributes' => ['id', 'topic', 'created_at']]]);
     $dataProvider->sort->defaultOrder = ['id' => SORT_DESC];
     $dataProvider->pagination->pageSize = Yii::$app->session->get('per-page', 20);
     if (!($this->load($params) && $this->validate())) {
         $dataProvider->query->joinWith(['messageReceivers' => function ($q) {
             $q->joinWith(['receiver']);
         }]);
         return $dataProvider;
     }
     $dataProvider->query->andFilterWhere(['like', 'topic', $this->topic]);
     if (preg_match('/^(forum|orum|rum|um|m)?#([0-9]+)$/', strtolower($this->receiverName), $matches)) {
         $dataProvider->query->joinWith(['messageReceivers' => function ($q) use($matches) {
             $q->joinWith(['receiver' => function ($q) use($matches) {
                 $q->andFilterWhere(['username' => ['', null], User::tableName() . '.id' => $matches[2]]);
             }]);
         }]);
     } elseif (preg_match('/^([0-9]+)$/', $this->receiverName, $matches)) {
         $dataProvider->query->joinWith(['messageReceivers' => function ($q) use($matches) {
             $q->joinWith(['receiver' => function ($q) use($matches) {
                 $q->andFilterWhere(['or', ['like', 'username', $this->receiverName], ['username' => ['', null], 'id' => $matches[1]]]);
             }]);
         }]);
     } else {
         $dataProvider->query->joinWith(['messageReceivers' => function ($q) {
             $q->joinWith(['receiver' => function ($q) {
                 $q->andFilterWhere(['like', User::tableName() . '.username', $this->receiverName]);
             }]);
         }]);
     }
     return $dataProvider;
 }
开发者ID:gitter-badger,项目名称:yii2-podium,代码行数:42,代码来源:MessageSearch.php

示例3: send

 /**
  * Sends message.
  * @return boolean
  */
 public function send()
 {
     $transaction = static::getDb()->beginTransaction();
     try {
         $this->sender_id = User::loggedId();
         $this->sender_status = self::STATUS_READ;
         if ($this->save()) {
             $count = count($this->receiversId);
             foreach ($this->receiversId as $receiver) {
                 if (!(new Query())->select('id')->from(User::tableName())->where(['id' => $receiver, 'status' => User::STATUS_ACTIVE])->exists()) {
                     if ($count == 1) {
                         throw new Exception('No active receivers to send message to!');
                     } else {
                         continue;
                     }
                 }
                 $message = new MessageReceiver();
                 $message->message_id = $this->id;
                 $message->receiver_id = $receiver;
                 $message->receiver_status = self::STATUS_NEW;
                 if ($message->save()) {
                     Cache::getInstance()->deleteElement('user.newmessages', $receiver);
                 } else {
                     throw new Exception('MessageReceiver saving error!');
                 }
             }
             $transaction->commit();
             $sessionKey = 'messages.' . $this->sender_id;
             if (Yii::$app->session->has($sessionKey)) {
                 $sentAlready = explode('|', Yii::$app->session->get($sessionKey));
                 $sentAlready[] = time();
                 Yii::$app->session->set($sessionKey, implode('|', $sentAlready));
             } else {
                 Yii::$app->session->set($sessionKey, time());
             }
             return true;
         } else {
             throw new Exception('Message saving error!');
         }
     } catch (Exception $e) {
         $transaction->rollBack();
         Log::error($e->getMessage(), $this->id, __METHOD__);
     }
     return false;
 }
开发者ID:pezisc,项目名称:yii2-podium,代码行数:49,代码来源:Message.php

示例4: send

 /**
  * Sends message.
  * @return boolean
  */
 public function send()
 {
     if (!(new Query())->select('id')->from(User::tableName())->where(['id' => $this->receiver_id, 'status' => User::STATUS_ACTIVE])->exists()) {
         return false;
     }
     $this->sender_id = User::loggedId();
     $this->sender_status = self::STATUS_READ;
     $this->receiver_status = self::STATUS_NEW;
     if ($this->save()) {
         Cache::getInstance()->deleteElement('user.newmessages', $this->receiver_id);
         return true;
     }
     return false;
 }
开发者ID:Avenger1,项目名称:yii2-podium,代码行数:18,代码来源:Message.php


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