Doctrine ORM
0
Вклад в тег
entityA:
type: entity
table: tableName_A
id:
id:
type: integer
column: id
generator:
strategy: AUTO
manyToOne:
role:
targetEntity: entityB
joinColumn:
name: cityId
referencedColumnName: id
cascade: ["persist"]
$entityA->role = new entityB(//params);
$entityA->role = $em->getReference(entityB::class, $entityBId);
This concept is called Persistence by Reachability: New entities that are found on already managed entities are automatically persisted as long as the association is defined as cascade: persist.