Situation:
I have 3 tables: Student, Address, StudentAddressLink As follows Note* not EXACT yaml file but you get the idea
Student:
column:
id: blah blah
name: blah blah
Address:
column:
id: ~
street: ~
StudentAddressLink:
column:
id:~
student_id: ~
address_id: ~
relations:
Student:
local: student_id
foreign: id
Address:
local: address_id
foreign: id
From the Student object I want to get the related “Address Street”
currently I have to do this:
foreach($student->StudentAddressLink as $address)
{
echo $address->getStreet();
}
This works…but I though there was a way to do something that makes the link table transparent, something magical like this:
foreach($student->Addresss as $address)
{
echo $address->getStreet();
}
Any direction would be great!
If you want many-to-many relations, you need to use something like the code here (for an out of date version of symfony but still correct).
This involves setting the
refClassasStudentAddressLink, allowing the transparent relationship that you want. You will then be able to use$student->Address[0]->getStreet, for example. The documentation there can explain better than I can!Edit I think your schema needs to look something like this: