简体   繁体   English

未为Codeigniter DataMapper ORM中的深层关系实例化对象

[英]Object is not instantiated for deep relationships in Codeigniter DataMapper ORM

From this example: 从这个例子:

http://datamapper.wanwizard.eu/pages/getadvanced.html#Deep.Relationship.Include http://datamapper.wanwizard.eu/pages/getadvanced.html#Deep.Relationship.Include

You can see that it says: At this time, deep relationships do not support instatiation. 您会看到它说: 此时,深层关系不支持声明。 .

So if we have some methods defined in the Group model, it still can't be used unless we manually collect the field data and instantiate the group object ourselves. 因此,如果我们在组模型中定义了一些方法,除非我们手动收集字段数据并自己实例化组对象,否则仍然无法使用它。

I am interested in why it's not supported, is this something very difficult to achieve for an ORM? 我对为什么不支持它感兴趣,这对于ORM而言很难实现吗?

Also, I would very much like to know if there is any easy workaround or how you solved this problem. 另外,我非常想知道是否有任何简单的解决方法或您如何解决此问题。

You can instantiate related objects when you use include_related(), but you can not instantiate deep relations ( like include_related('groups/users/posts/comments') ), the code simply doesn't support it. 您可以在使用include_related()时实例化相关对象,但不能实例化深层关系(如include_related('groups / users / posts / comments')),代码根本不支持它。

Remember that DataMapper has been around for quite a few years, and the current v1.x codebase still supports CodeIgniter 1.7. 请记住,DataMapper已经存在了很多年,并且当前的v1.x代码库仍支持CodeIgniter 1.7。 Which means it contains a fair amount of PHP4 legacy code. 这意味着它包含大量的PHP4旧代码。

I'm busy designing DataMapper v2, which will address this issue. 我正在忙于设计DataMapper v2,它将解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM