3

我一直在尝试使我的学说 2 设置为模块化结构。尝试创建实体时收到此错误:

Entity has to be managed for single computation Entities\User@0000000078d19339000000004266cb59

代码:

/* Test Doctrine */
        $em = Zend_Registry::get('em');
        $user = new Entities\User();
        $user->name = "Bob";
        $user->username = "bob";
        $user->email = "bob@live.com";
        $user->password = "test";
        $user->activation = "";
        $em->flush($user);
        $em->persist();
4

1 回答 1

6

可恶...

我自己都尴尬了!这是一个黄金法则问题...

修复:

/* Test Doctrine */
        $em = Zend_Registry::get('em');
        $user = new Entities\User();
        $user->name = "Bob";
        $user->username = "bob";
        $user->email = "bob@live.com";
        $user->password = "test";
        $user->activation = "";
        $em->persist($user); // The other way around :D
        $em->flush();
于 2012-07-05T02:39:54.323 回答