drfals1307 2012-04-24 14:33
浏览 50
已采纳

在域模型中获取对象相关对象

How to take care of fetching related objects of one object? For example object project has some tags. How and when should I fetch those object? In user initialization in mapper? That would be a big overload. The best way would be to load them dynamicly when system ask user for tags, but how to do that if model does not know anything about the mapper? Or just use Doctrine and forgot all about those problems?

Im asking this in relation to PHP Zend Framework. But any technology would suffice I think for this problem.

  • 写回答

1条回答 默认 最新

  • dongqiang4819 2012-04-24 20:13
    关注

    It is difficult to answer your question because you are not referring to a specific ORM or framework. If you are looking for suggestions, I would recommend using Doctrine as the model API and Zend Framework as a stand-alone library.

    If you need a full featured framework you can take a look at any of these:

    1. Symfony2
    2. CakePHP
    3. Zend Framework (as a framework vs stand-alone lib)
    4. CodeIgniter

    If you choose to go with Doctrine as your ORM, you can setup the schema file to ensure objects are relationship aware, then you can make references like:

    // Joins tags table by way of intermediary object_tag table providing
    //  a M:1, 1:M relationship
    $tags = $object->getTags();
    

    Doctrine (1.2 not sure about 2.x) does employ lazy loading pattern, where the objects are only queried when requested.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?