I'm busy with a project in Symfony and I'm just checking the profiler tab and seeing 2 errors continuously popping up - they are below.
The mappings MyBundle\MainBundle\Entity\School#provinceId and MyBundle\MainBundle\Entity\Province#schools are incosistent with each other.
The association MyBundle\MainBundle\Entity\School#grades refers to the owning side field MyBundle\MainBundle\Entity\Grade#school_id which does not exist.
I'm getting a couple more of these and I can't understand why? What does it mean by "incosistent" (see what I did there)? Parts of my code is below if it's helpful.
In Province.php
/**
* @ORM\OneToMany(targetEntity="School", mappedBy="provinceId")
*/
private $schools;
and in my Schools.php
/**
* @var integer
*
* @ORM\ManyToOne(targetEntity="Province", inversedBy="schools")
* @ORM\JoinColumn(name="province_id", referencedColumnName="id")
*/
private $provinceId;
And for the second error...
School.php
/**
* @ORM\OneToMany(targetEntity="Grade", mappedBy="school_id")
*/
private $grades;
and Grade.php
/**
* @var integer
*
* @ORM\ManyToOne(targetEntity="School", inversedBy="grades")
* @ORM\JoinColumn(name="school_id", referencedColumnName="id")
*/
private $schoolId;
I just want to know what these errors mean exactly and why these entities aren't right - I tried following the docs off the doctrine page but apparently I went wrong somewhere!
Thanks for any help!
I don't have your entire configuration, so I'm just going to make an educated guess here... (forgive me if I'm wrong!)
Regarding the first one, you say the mapping looks like this:
I imagine it's the types that are throwing things off here. You see, the purpose of the mappings is so that you can treat these things like objects, without having to worry about how they're persisted/connected in the database. Specifically, in your case, a
School
entity should not have a member$provinceId
of typeinteger
; rather, it should have a$province
of typeProvince
.Try this:
(Again, this is wholly untested, and I only have a part of what you have... but I think this will get you closer.)