我环顾四周,这个问题与这个问题类似,但没有一个对我有效的答案。
在ZendFramework1.6中,使用Doctrine 2和类的名称空间构建,Doctrine已经使用它的迁移工具构建了模式。
我的代码如下:
doctrine2 OneToMany relationship inserts NULL as the foreign key

最佳答案

你是不是碰巧错过了“双重绑定”实体。例如,您需要执行以下操作:

$forum = .... // some forum
$thread = .... // new thread;

$forum->getThreads()->add($thread); // first add to list
$thread->setForum($forum); // but also set forum parent within `Thread`

然后像往常一样保存实体…

关于php - Doctrine 实体一对多关系将外键保存为NULL,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9785470/

10-10 03:18