Can't find field in polymorphic association with Doctrine2
I have a polymorphic association (Class Inheritance) and I need to use DQL to query objects of a specific child class, which can be done using "x INSTANCE OF Entity" in the WHERE clause. Now I need to set conditions specific to this child class, but I am getting this error:
"The Person class has no association with the student_field_1 name"
Person = parent class
Employee = child class
Student = child's class
Is there any way that somehow explains the Doctrine that a Person is actually a Student and allows me to put the Student's t fields in WHERE?
source to share
It looks like "Mapped Superclass" is more suitable for what you are trying to do as it doesn't require an explicit parent / child relationship, its simple inheritance.
With class table inheritance, you need to provide a discriminator map that links the two objects using a key.
"The table of the child class must be bound to the table of the parent class through a foreign key constraint"
source to share