[FLOW3-general] Self referencing M:N Relation
Cornel Widmer
cornel at kollerinternet.ch
Fri Mar 1 18:38:51 CET 2013
Sorry folks
I really try hard to get over the starting problems. Most of my problems are ORM related ... so this one either.
I need a self referencing Many-to-Many relation. In my model i have the model company, with the property customers and providers. Each Company can have multiple Customers (Company-Model) and so every Company can have multiple Providers (Company-Model).
First try...
/**
* @var \Doctrine\Common\Collections\ArrayCollection<\WS\Rico\Domain\Model\Company>
* @ORM\ManyToMany(mappedBy="companyCustomers")
* @ORM\Column(nullable=true)
*/
protected $companyProviders;
/**
* @var \Doctrine\Common\Collections\ArrayCollection<\WS\Rico\Domain\Model\Company>
* @ORM\ManyToMany(inversedBy="companyProviders")
* @ORM\Column(nullable=true)
*/
protected $companyCustomers;
The first update with doctrine:update was successfull, but something is wrong. No associations are stored in the database. When I try to update the Database again I'm getting errors.
How to do that?
I also tried to adopt the example of doctrine ... but not with usable results.
http://docs.doctrine-project.org/en/2.0.x/reference/association-mapping.html#many-to-many-self-referencing
More information about the FLOW3-general
mailing list