本文整理汇总了PHP中common\models\User::tableName方法的典型用法代码示例。如果您正苦于以下问题:PHP User::tableName方法的具体用法?PHP User::tableName怎么用?PHP User::tableName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common\models\User
的用法示例。
在下文中一共展示了User::tableName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionTopic
public function actionTopic($username)
{
$this->title = $username . '提的建议 - ' . Yii::$app->name;
$this->description = '';
$this->canonical = Yii::$app->params['domain'] . 'member/' . $username . '/topic';
$user = $this->findModel($username);
$query = (new Query())->select('topic.*, node.enname, node.name, user.username, user.avatar')->from(Topic::tableName())->leftJoin(Node::tableName(), 'node.id = topic.node_id')->leftJoin(User::tableName(), 'user.id = topic.user_id')->where(['node.is_hidden' => 0])->andWhere(['topic.user_id' => $user->id]);
$pagination = new Pagination(['defaultPageSize' => Yii::$app->params['pageSize'], 'totalCount' => $query->count()]);
$model = $query->orderBy(['id' => SORT_DESC])->offset($pagination->offset)->limit($pagination->limit)->all();
return $this->render('topic', ['model' => $model, 'user' => $user, 'pagination' => $pagination]);
}
示例2: actionUserMobileFilter
public function actionUserMobileFilter($q = null, $id = null)
{
Yii::$app->response->format = Response::FORMAT_JSON;
$output = ['results' => ['id' => '', 'text' => '']];
if (!is_null($q)) {
$sql = 'SELECT id, mobile AS text FROM ' . User::tableName() . ' WHERE mobile LIKE :like ORDER BY mobile ASC LIMIT 25';
$output['results'] = Yii::$app->db->createCommand($sql, [':like' => "%{$q}%"])->queryAll();
} elseif ($id > 0 && ($user = User::findOne($id))) {
$output['results'] = ['id' => $id, 'text' => $user->mobile];
}
return $output;
}
示例3: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = MediaModel::find()->from(['media' => $this->tableName()]);
$query->innerJoinWith(['mediaAuthor' => function ($query) {
/* @var $query \yii\db\ActiveQuery */
return $query->from(['author' => User::tableName()]);
}]);
$query->leftJoin(['post' => Post::tableName()], 'media.media_post_id = post.id');
$dataProvider = new ActiveDataProvider(['query' => $query]);
$dataProvider->setSort(['attributes' => ArrayHelper::merge($dataProvider->sort->attributes, ['username' => ['asc' => ['username' => SORT_ASC], 'desc' => ['username' => SORT_DESC], 'label' => 'Author', 'value' => 'username']]), 'defaultOrder' => ['id' => SORT_DESC]]);
$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, 'media_author' => $this->media_author, 'media_post_id' => $this->media_post_id, 'media_comment_count' => $this->media_comment_count]);
$query->andFilterWhere(['like', 'media_title', $this->media_title])->andFilterWhere(['like', 'media_excerpt', $this->media_excerpt])->andFilterWhere(['like', 'media_content', $this->media_content])->andFilterWhere(['like', 'media_password', $this->media_password])->andFilterWhere(['like', 'media_slug', $this->media_slug])->andFilterWhere(['like', 'media_mime_type', $this->media_mime_type])->andFilterWhere(['like', 'media_comment_status', $this->media_comment_status])->andFilterWhere(['like', 'media_date', $this->media_date])->andFilterWhere(['like', 'media_modified', $this->media_modified])->andFilterWhere(['like', 'post.post_title', $this->post_title])->andFilterWhere(['like', 'author.username', $this->username]);
return $dataProvider;
}
示例4: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Post::find();
// add conditions that should always apply here
$dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]);
$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;
}
// grid filtering conditions
$post = Post::tableName();
$user = User::tableName();
$query->andFilterWhere([$post . '.id' => $this->id, $post . '.status' => $this->status, 'create_time' => $this->create_time, 'update_time' => $this->update_time, 'author_id' => $this->author_id]);
$query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'tags', $this->tags]);
$query->join('INNER JOIN', $user, $post . '.author_id = User.id');
$query->andFilterWhere(['like', $user . '.username', $this->username]);
return $dataProvider;
}
示例5: actionView
public function actionView($nodeName)
{
$node = $this->findModel($nodeName);
if ($node->need_login == 1 && Yii::$app->user->isGuest) {
Yii::$app->getSession()->setFlash('danger', '你访问的节点需要登陆之后才能查看');
return $this->redirect('/account/login?next=/node/' . $nodeName);
}
if (!empty($node->bg) && $node->use_bg == 1) {
$this->bg = $node->bg;
}
if (!empty($node->bg_color)) {
$this->bg_color = $node->bg_color;
}
$this->title = $node->name . ' - ' . Yii::$app->name;
$this->description = '';
$this->canonical = Yii::$app->params['domain'] . 'node/' . $nodeName;
$query = (new Query())->select('topic.*, node.enname, node.name, user.username, user.avatar')->from(Topic::tableName())->leftJoin(Node::tableName(), 'node.id = topic.node_id')->leftJoin(User::tableName(), 'user.id = topic.user_id')->where(['node.id' => $node->id]);
$pagination = new Pagination(['defaultPageSize' => Yii::$app->params['pageSize'], 'totalCount' => $query->count()]);
$model = $query->orderBy(['id' => SORT_DESC])->offset($pagination->offset)->limit($pagination->limit)->all();
return $this->render('view', ['model' => $model, 'node' => $node, 'pagination' => $pagination]);
}
示例6: findActiveUser
/**
* 查找活跃用户
* @param int $limit
* @return array|\yii\db\ActiveRecord[]
*/
public static function findActiveUser($limit = 12)
{
$cacheKey = md5(__METHOD__ . $limit);
if (false === ($items = \Yii::$app->cache->get($cacheKey))) {
$items = User::find()->joinWith(['merit', 'userInfo'])->where([User::tableName() . '.status' => 10])->orderBy(['merit' => SORT_DESC, '(like_count+thanks_count)' => SORT_DESC])->limit($limit)->all();
//一天缓存
\Yii::$app->cache->set($cacheKey, $items, 86400, new TagDependency(['tags' => [NamingHelper::getCommonTag(User::className())]]));
}
return $items;
}
示例7: actionRecent
public function actionRecent()
{
$this->title = '最近的主题 - ' . Yii::$app->name;
$this->description = '';
$pagination = new Pagination(['defaultPageSize' => Yii::$app->params['pageSize'], 'totalCount' => (new Query())->from(Topic::tableName() . ' topic')->leftJoin(Node::tableName() . ' node', 'node.id = topic.node_id')->where('node.is_hidden = 0')->count()]);
$topic = (new Query())->select('topic.*, node.enname, node.name, user.username, user.avatar')->from(Topic::tableName() . ' topic')->leftJoin(Node::tableName() . ' node', 'node.id = topic.node_id')->leftJoin(User::tableName() . ' user', 'user.id = topic.user_id')->where('node.is_hidden = 0')->orderBy(['topic.id' => SORT_DESC])->offset($pagination->offset)->limit($pagination->limit)->all();
return $this->render('recent', ['topic' => $topic, 'pagination' => $pagination]);
}
示例8: HotTopic
/**
* 热门主题
* @param int $num 获取几条热门主题
* @return array|\yii\db\ActiveRecord[]
*/
static function HotTopic($num = 8)
{
return $topic = (new Query())->select('topic.*, user.username, user.avatar')->from(Topic::tableName() . ' topic')->leftJoin(Node::tableName() . ' node', 'node.id = topic.node_id')->leftJoin(User::tableName() . ' user', 'user.id = topic.user_id')->where('node.is_hidden = 0')->andWhere(['between', 'topic.created', strtotime(date('Y-m-d H:i', time())) - 86400, strtotime(date('Y-m-d H:i', time()))])->orderBy(['topic.reply' => SORT_DESC])->limit($num)->all();
}
示例9:
<?php
return ['adminEmail' => 'admin@example.com', 'supportEmail' => 'support@example.com', 'user.passwordResetTokenExpire' => 3600, 'mdm.admin.configs' => ['userTable' => \common\models\User::tableName(), 'menuTable' => '{{%auth_menu}}'], 'ckeditorConfig' => ['language' => 'zh-cn', 'font_names' => '宋体;楷体;黑体;微软雅黑;隶书;仿宋;Arial;Comic Sans MS;Courier New;Tahoma;Times New Roman;Verdana']];
示例10: safeUp
/**
* @inheritdoc
*/
public function safeUp()
{
$this->createTable($this->tableName, ['id' => $this->primaryKey(), 'model_name' => $this->string()->notNull(), 'model_id' => $this->integer()->notNull(), 'user_id' => $this->integer()->defaultValue(null) . ' COMMENT "User"', 'name' => $this->string()->defaultValue(null) . ' COMMENT "Name"', 'content' => $this->text()->notNull() . ' COMMENT "Content"', 'tree' => $this->integer()->defaultValue(null), 'lft' => $this->integer()->notNull(), 'rgt' => $this->integer()->notNull(), 'depth' => $this->integer()->notNull(), 'status_id' => $this->smallInteger(2)->notNull()->defaultValue(0) . ' COMMENT "Status"', 'published' => $this->boolean()->notNull()->defaultValue(1) . ' COMMENT "Published"', 'position' => $this->integer()->notNull()->defaultValue(0) . ' COMMENT "Position"', 'created_at' => $this->integer()->notNull() . ' COMMENT "Created at"', 'updated_at' => $this->integer()->notNull() . ' COMMENT "Updated at"'], $this->tableOptions);
$this->addForeignKey('fk-comment-user_id-user-id', $this->tableName, 'user_id', \common\models\User::tableName(), 'id', 'SET NULL', 'CASCADE');
}
示例11: User
/**
* 获取我关注的人
* @param bool $onlyId
* @return array|\yii\db\ActiveRecord[]
*/
static function User($onlyId = true)
{
if ($onlyId) {
if (!($FollowUser = Yii::$app->cache->get('FollowUserId' . Yii::$app->user->id))) {
$FollowUser = ArrayHelper::map(Follow::find()->select('follow_id')->where(['user_id' => Yii::$app->user->id, 'type' => 1])->asArray()->all(), 'follow_id', 'follow_id');
Yii::$app->cache->set('FollowUserId' . Yii::$app->user->id, $FollowUser, 0);
}
} else {
if (!($FollowUser = Yii::$app->cache->get('FollowUser' . Yii::$app->user->id))) {
$FollowUser = (new Query())->from(User::tableName())->where(['in', 'id', Follow::User()])->all();
Yii::$app->cache->set('FollowUser' . Yii::$app->user->id, $FollowUser, 0);
}
}
return $FollowUser;
}
示例12: actionView
/**
* Displays a single Topic model.
* @param integer $id
* @return mixed
* @throws BadRequestHttpException
* @throws NotFoundHttpException
* @throws \Exception
*/
public function actionView($id)
{
$model = $this->findModel($id);
if ($model->need_login == 1 && Yii::$app->user->isGuest) {
Yii::$app->getSession()->setFlash('danger', '你访问的建议需要登陆之后才能查看');
return $this->redirect('/account/login?next=/topic/' . $id);
}
if (!empty($model->node->bg) && $model->node->use_bg == 1) {
$this->bg = $model->node->bg;
}
if (!empty($model->node->bg_color)) {
$this->bg_color = $model->node->bg_color;
}
$this->title = $model->title . ' - ' . Yii::$app->name;
if (isset($model->content->content)) {
$this->description = $model->node->name . ' - ' . $model->user->username . ' - ' . Helper::truncateUtf8String($model->content->content, 200);
} else {
$this->description = $model->node->name . ' - ' . $model->user->username . Helper::truncateUtf8String($model->title, 200);
}
$this->canonical = Yii::$app->params['domain'] . 'topic/' . $id;
$replyQuery = (new Query())->select('reply.*, user.username, user.avatar, user.role')->from(Reply::tableName())->leftJoin(User::tableName(), 'user.id = reply.user_id')->where(['reply.topic_id' => $id]);
$pagination = new Pagination(['defaultPageSize' => Yii::$app->params['ReplyPageSize'], 'totalCount' => $replyQuery->count()]);
$replyList = $replyQuery->offset($pagination->offset)->limit($pagination->limit)->all();
$reply = new Reply();
if (!Yii::$app->user->isGuest) {
$model->updateCounters(['click' => 1]);
$reply = new Reply();
if ($reply->load(Yii::$app->request->post()) && $reply->save()) {
Yii::$app->cache->delete('ReplyCount');
$this->redirect('/topic/' . $id . '#Reply');
}
return $this->render('view', ['model' => $model, 'reply' => $reply, 'replyList' => $replyList, 'pagination' => $pagination]);
} else {
return $this->render('view', ['model' => $model, 'reply' => $reply, 'replyList' => $replyList, 'pagination' => $pagination]);
}
}
示例13: findActiveUser
/**
* 查找活跃用户
* @param int $limit
* @return array|\yii\db\ActiveRecord[]
*/
public static function findActiveUser($limit = 12)
{
return User::find()->joinWith(['merit', 'userInfo'])->where([User::tableName() . '.status' => 10])->orderBy(['merit' => SORT_DESC, '(like_count+thanks_count)' => SORT_DESC])->limit($limit)->all();
}
示例14: getREQPlanOfId
/**
* 根据原始ID获取最新的续约订单
* @param $id
*/
public static function getREQPlanOfId($id)
{
if (empty($id)) {
return false;
}
$record_arr = (new Query())->from(PlanRecord::tableName() . ' as pr')->select(['pr.id', 'u.username', 'u.realname', 'pr.money_insure', 'pr.money_op', 'pr.money_warning', 'pr.money_force', 'pr.money_settlement', 'pr.status', 'pr.parent_id'])->leftJoin(User::tableName() . ' as u', 'pr.user_id = u.id')->where(['pr.parent_id' => $id, 'pr.parent_type' => PlanRecord::PARENT_TYPE_RENEW])->one();
if (empty($record_arr)) {
return false;
}
if ($record_arr['status'] == PlanRecord::STATUS_EXPIRED) {
return self::getREQPlanOfId($record_arr['id']);
}
return $record_arr;
}
示例15: getUserEgreso
public function getUserEgreso()
{
return $this->hasOne(\common\models\User::className(), ['id' => 'egr_id_user'])->from(\common\models\User::tableName() . ' uegr');
}