Menu
  • HOME
  • TAGS

Yii2 Not unique table/alias: 'user'

yii2,table-alias

You missed space before alias. Should be: public function getSupervisor() { return $this->hasOne(User::className(), ['id' => 'supervisor_id']) ->from(User::tableName() . ' u2'); } You can also specify it as array key: public function getSupervisor() { return $this->hasOne(User::className(), ['id' => 'supervisor_id']) ->from(['u2' => User::tableName()]); } Or even in joinWith() with this relation: ->joinWith([...