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


PHP ActiveQuery::leftJoin方法代码示例

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


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

示例1: setupFilters

 /**
  * Setup additional filters
  */
 public function setupFilters()
 {
     if (in_array('entry_files', $this->filters)) {
         $fileSelector = (new \yii\db\Query())->select(["id"])->from('file')->where('file.object_model=content.object_model AND file.object_id=content.object_id')->limit(1);
         $fileSelectorSql = Yii::$app->db->getQueryBuilder()->build($fileSelector)[0];
         $this->activeQuery->andWhere('(' . $fileSelectorSql . ') IS NOT NULL');
     }
     // Setup Post specific filters
     if (in_array('posts_links', $this->filters)) {
         $this->activeQuery->leftJoin('post', 'content.object_id=post.id AND content.object_model=:postModel', ['postModel' => \humhub\modules\post\models\Post::className()]);
         $this->activeQuery->andWhere("post.url is not null");
     }
     // Only apply archived filter when we should load more than one entry
     if ($this->limit != 1) {
         if (!in_array('entry_archived', $this->filters)) {
             $this->activeQuery->andWhere("(content.archived != 1 OR content.archived IS NULL)");
         }
     }
     // Show only mine items
     if (in_array('entry_mine', $this->filters) && $this->user !== null) {
         $this->activeQuery->andWhere(['content.created_by' => $this->user->id]);
     }
     // Show only items where the current user is involed
     if (in_array('entry_userinvoled', $this->filters) && $this->user !== null) {
         $this->activeQuery->leftJoin('user_follow', 'content.object_model=user_follow.object_model AND content.object_id=user_follow.object_id AND user_follow.user_id = :userId', ['userId' => $this->user->id]);
         $this->activeQuery->andWhere("user_follow.id IS NOT NULL");
     }
     if (in_array('model_posts', $this->filters)) {
         $this->activeQuery->andWhere(["content.object_model" => \humhub\modules\post\models\Post::className()]);
     }
     // Visibility filters
     if (in_array('visibility_private', $this->filters)) {
         $this->activeQuery->andWhere(['content.visibility' => Content::VISIBILITY_PRIVATE]);
     }
     if (in_array('visibility_public', $this->filters)) {
         $this->activeQuery->andWhere(['content.visibility' => Content::VISIBILITY_PUBLIC]);
     }
 }
开发者ID:VasileGabriel,项目名称:humhub,代码行数:41,代码来源:Stream.php


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