What is the actual question - there is such a table:

/** * @ORM\Column(type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") * @ORM\OneToMany(targetEntity="Category", mappedBy="parent") */ private $id; /** * @ORM\Column(type="string", length=100) */ private $name; /** * @ORM\Column(type="string", length=100) */ private $slug; /** * @ORM\ManyToOne(targetEntity="Category", inversedBy="id") * @ORM\JoinColumn(name="parent", referencedColumnName="id", unique=false) */ private $parent; public function __toString() { return (String) $this->getParent(); } /** * @ORM\ManyToMany(targetEntity="Post", mappedBy="category", cascade={"persist"}) */ private $posts; public function __construct() { $this->posts = new \Doctrine\Common\Collections\ArrayCollection(); } 

Is there any ready-made method in ORM or in SYMFONY so that when adding data to the table it was impossible to do so:

enter image description here

Or do you need to do the checking yourself before adding the data?

I would be very grateful for the answers! Thank.

    1 answer 1

    At the level of mapping or database schema is not prohibited. Check the relationships between entities during the validation phase.