本文整理汇总了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]);
}
}