Doctrine problem (comparisons are inconsistent)

I am busy with a project in Symfony, and I just check the profiler tab and see how 2 errors constantly appear - they are lower.

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 get a couple more of these, and I don’t understand why? What does “inconstancy” mean (see. What have I done there)? Details of my code are below if this is 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 and why these entities are wrong - I tried to follow the documents from the page of the doctrine, but apparently I was mistaken somewhere!

Thanks for any help!

+4
source share
1 answer

, ... ( , !)

, , :

# Province.php
/**
  * @ORM\OneToMany(targetEntity="School", mappedBy="provinceId")
 */ 
private $schools;

# School.php
/**
 * @var integer
 *
 * @ORM\ManyToOne(targetEntity="Province", inversedBy="schools")
 * @ORM\JoinColumn(name="province_id", referencedColumnName="id")
 */
private $provinceId;

, . , , , , / . , School $provinceId integer; , $province Province.

:

# Province.php
/**
  * @ORM\OneToMany(targetEntity="School", mappedBy="province")
 */ 
private $schools;

# School.php
/**
 * @var Province
 *
 * @ORM\ManyToOne(targetEntity="Province", inversedBy="schools")
 * @ORM\JoinColumn(name="province_id", referencedColumnName="id")
 */
private $province;

( , , , ... , .)

+9

All Articles