douyi8760 2013-04-05 20:09
浏览 49
已采纳

在Zend Framework中使用Doctrine中的PersistentObject

I have a question for you all. I'm just starting to use Zend Framework after I have used Codeigniter for about 1 year now. I have installed everything and everything is running now. But I have one problem. I want to use Doctrine for my modelling. And I always used the PersistentObject from Doctrine, but I can't seem to get it working.

The problem is that I need to pass through a ObjectManager to the PersistentObject. But I can't make it work. Does anybody have any idea how I can pass through the ObjectManger from the DoctrineORM module to the PersistentObject?

If I'm not clear enough you can tell me. It's a bit an hassle for me to speak english. I'm sorry about that!

  • 写回答

1条回答 默认 最新

  • donglei2288 2013-04-06 00:59
    关注

    You could do it in your Module's onBootstrap() method:

    <?php
    namespace MyApplication;
    use Doctrine\Common\Persistence\PersistentObject;
    
    class Module {
    
        public function onBootstrap($e){
            $serviceManager = $e->getApplication()->getServiceManager();
            PersistentObject::setObjectManager($sm->get('Doctrine\ORM\EntityManager');
        }
    
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!