Ich benutze yii2 Framework und versuche, mehrere Tabellen zu verbinden.Mehrere Tabellen in GridView verbinden
Ich habe es geschafft, 3 Tabellen zusammen zu verbinden, aber ich bin nicht klar, wie Sie das auf 4 Tabellen erweitern.
I joined three tables as follows >>>
//In Tasks Model
public function getLocation()
{
return $this->hasOne(Locations::className(),
['id' => 'location_id']);
}
//in current Model
public function getLocation()
{
return $this->hasOne(Tasks::className(),['id'=>'task_id'])
->with(['location']);
}
//then in grid view
....
'columns' => [
[
....
[
class' => 'kartik\grid\DataColumn',
'label' => 'Name',
'value' => 'tasks.location.name',
],
....
Also das funktioniert gut, aber ich möchte jetzt eine zusätzliche Tabelle im Zusammenhang mit Standorten beitreten. Der Join wäre locations.task_group_id = task_group.id. Voll verbinden wie folgt
**** Ich konnte mit über diesem ****
responses.task_id = tasks..id
tasks.location_id = locations.id
locations-> Name (Name das Feld in der Tabelle Orten sein)
Wie mache ich das?
responses.task_id = tasks..id
tasks.location_id = locations.id
locations.task_group.id = task_group.id
task_group-> name (Name ist das Feld in der Tabelle task_group)