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