I'm trying to create a "OneToMany" bidirectional association in my project but when I execute "doctrine:schema:update" nothing happens.
If I create this association directly from Sequel Pro and run the update schema command, that changes dissapear... :/
The relations is: - One "id" from Customers Table with many "customer_id" form Control table.
Here is the Customers code:
<?php namespace Ourentec\CustomersBundle\Entity; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\Mapping as ORM; /** * Customers * * @ORM\Table() * @ORM\Entity */ class Customers { /* @var integer * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @var string * * @ORM\Column(name="name", type="string", length=100) */ private $name; /** * @var string * * @ORM\Column(name="lastname", type="string", length=100) */ private $lastname; /** * @var string * * @ORM\Column(name="address", type="text") */ private $address; /** * @var string * * @ORM\Column(name="phone", type="string", length=100) */ private $phone; /** * @var string * * @ORM\Column(name="pass", type="string", length=100) */ private $pass; /** * @var string * * @ORM\Column(name="tasks", type="text") */ private $tasks; /** * @var string * * @ORM\Column(name="status", type="string", length=100) */ private $status; /** * @var string * * @ORM\Column(name="email", type="string", length=100) */ private $email; /** * @var \DateTime * * @ORM\Column(name="date", type="datetime") */ private $date; /** * @var string * * @ORM\Column(name="location", type="string", length=100) */ private $location; /** * @ORM\OneToMany(targetEntity="Control", mappedBy="customers") */ private $customer_id; public function __construct() { $this->customer_id = new ArrayCollection(); } And the Control code:
<?php namespace Ourentec\CustomersBundle\Entity; use Doctrine\ORM\Mapping as ORM; /** * Control * * @ORM\Table() * @ORM\Entity */ class Control { /** * @var integer * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @var integer * * @ORM\Column(name="customer_id", type="integer") * * @ORM\ManyToOne(targetEntity="Customers", inversedBy="control") * @ORM\JoinColumn(name="customer_id", referencedColumnName="id") */ private $customerId; /** * @var integer * * @ORM\Column(name="user_id", type="integer") */ private $userId; /** * @var \DateTime * * @ORM\Column(name="date", type="datetime") */ private $date; /** * @var integer * * @ORM\Column(name="seen", type="smallint") */ private $seen; I followed the documentation from this 2 websites http://symfony.com/doc/current/book/doctrine.html http://librosweb.es/libro/symfony_2_x/capitulo_8/relaciones_y_asociaciones_de_entidades.html
But I don't know why it does not work..
Any idea will be appreciated :)