简体   繁体   中英

Doctrine2 relations - how to set inexistant associate entity object

I have 2 entities: SectionAdmin and Section.

The relation is ManyToOne from SectionAdmin to Section.

Now, in the MySQL table, I can add section_id to be 0, that means that the SectionAdmin will be admin of all the sections, but Doctrine is not allowing me to do that.

I need to specify a valid Section object.

Any idea on how to do that?

I did this in an easier way:

$insertEditorRightSQL = "INSERT INTO section_admin(section_id) VALUES (0) ";

$insertEditorRight = $em->getConnection()->prepare($insertEditorRightSQL); 
$insertEditorRight->execute();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM