1
0
mirror of synced 2025-01-05 16:53:21 +03:00

Updated docs (trying to fix one-to-many with unidirectional join table example).

This commit is contained in:
Guilherme Blanco 2012-05-28 12:39:31 -04:00
parent 4627c8b3ee
commit 8b4e08d694

View File

@ -223,9 +223,15 @@ One-To-Many, Unidirectional with Join Table
A unidirectional one-to-many association can be mapped through a A unidirectional one-to-many association can be mapped through a
join table. From Doctrine's point of view, it is simply mapped as a join table. From Doctrine's point of view, it is simply mapped as a
unidirectional many-to-many whereby a unique constraint on one of unidirectional many-to-many whereby a unique constraint on one of
the join columns enforces the one-to-many cardinality. The the join columns enforces the one-to-many cardinality.
following example sets up such a unidirectional one-to-many
association: .. note::
One-To-Many uni-directional relations with join-table only
work using the @ManyToMany annotation and a unique-constraint.
The following example sets up such a unidirectional one-to-many association:
.. configuration-block:: .. configuration-block::
@ -246,7 +252,8 @@ association:
**/ **/
private $phonenumbers; private $phonenumbers;
public function __construct() { public function __construct()
{
$this->phonenumbers = new \Doctrine\Common\Collections\ArrayCollection(); $this->phonenumbers = new \Doctrine\Common\Collections\ArrayCollection();
} }
@ -293,11 +300,6 @@ association:
referencedColumnName: id referencedColumnName: id
unique: true unique: true
.. note::
One-To-Many uni-directional relations with join-table only
work using the @ManyToMany annotation and a unique-constraint.
Generates the following MySQL Schema: Generates the following MySQL Schema:
@ -323,6 +325,7 @@ Generates the following MySQL Schema:
ALTER TABLE users_phonenumbers ADD FOREIGN KEY (user_id) REFERENCES User(id); ALTER TABLE users_phonenumbers ADD FOREIGN KEY (user_id) REFERENCES User(id);
ALTER TABLE users_phonenumbers ADD FOREIGN KEY (phonenumber_id) REFERENCES Phonenumber(id); ALTER TABLE users_phonenumbers ADD FOREIGN KEY (phonenumber_id) REFERENCES Phonenumber(id);
Many-To-One, Unidirectional Many-To-One, Unidirectional
--------------------------- ---------------------------