/** * Establishing hasOne relation with Country table * @return \yii\db\ActiveQuery */ public function getCountry() { return $this->hasOne(Country::classname(), ['country_id' => 'comment_country_id']); /*Сначала ключ другой таблицы, потом своей === или сначала ключ таблицы, которую пишем после hasOne hasMany*/ }