Reputation: 89
I've looked around and this question doctrine2 OneToMany relationship inserts NULL as the foreign key is similar to this one but without an answer that works for me.
Build in Zend Framework 1.6 using Doctrine 2 and name spaces for classes, Doctrine has build the schema using it's migration tool.
My codes below:
Upvotes: 3
Views: 1471
Reputation: 20193
Did you by some chance miss to "double bind" 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 persist entities as usual...
Upvotes: 4