样本不包括表中的值

I have objects connected mano through the intermediate table.

class City{ /**
     * @return \yii\db\ActiveQuery
     */
    public function getReviews()
    {
        return $this->hasMany(Reviews::className(), ['id' => 'review_id'])
            ->viaTable('city_review', ['city_id' => 'id']);
    }
}

And get review for city:

  $reviews = $city2->getReviews()->all();

Question: How select reviews from reviews table, which are not in the table city_review?

I'm not familiar with yii activerecord syntax

But the query you need is below.

SELECT review.* FROM review 
LEFT JOIN city_review cr ON cr.city_id = review.id
WHERE cr.id IS NULL

This code should result similar to what you need but you need to test.

$reviews = Reviews::find()
    ->select('review.*')
    ->leftJoin('city_review', '`city_review`.`city_id` = `review`.`id`')
    ->where(['city_review.id' => NULL])
    ->with('city_reviews')
    ->all();