One-to-Many Doctrine Relationship Store Foreign Key as NULL
I looked around and this doctrine2 question OneToMany Interaction inserts NULL as a foreign key , similar to this one but no answer that works for me.
Build in Zend Framework 1.6 using Doctrine 2 and class namespaces, Doctrine will build the schema using the migration tool.
My codes are below:
+3
source to share
1 answer
You accidentally missed the "double binding" entities. That is, you need to do, for example:
$forum = .... // some forum
$thread = .... // new thread;
$forum->getThreads()->add($thread); // first add to list
$thread->setForum($forum); // but also set forum parent within `Thread`
and then save the objects as usual ...
+4
source to share