An User has one Package associated with it. Many users can refer to the same package. User cannot exist without Package . User must belong to a relation. The relationship is bidirectional, so Package has zero or more users.
These requirements lead to the ManyToOne relationship for the User and OneToMany Package relationships in Doctrine 2. However, the package_id table in User (that is, an external key) allows null values ββto be used. I tried setting nullable=false , but the command:
php app/console doctrine:generate:entities DL --path="src" --no-backup
Says there is no nullable attribute for the nullable . What am I missing?
class User { private $id; private $package; } class Package { private $id; private $users; }
EDIT : resolved. note that this is wrong (note the double quotes):
@ORM\JoinColumn(name="package_id", referencedColumnName="id", nullable="false")
So far this is correct:
@ORM\JoinColumn(name="package_id", referencedColumnName="id", nullable=false)
symfony doctrine doctrine2
gremo Mar 12 2018-12-12T00: 00Z
source share