开发者

Mixing Zend_Db with ORM Classes

开发者 https://www.devze.com 2023-01-18 16:35 出处:网络
Zend has Zend_Db but it\'s not a full ORM. I already have sections of an app written in a way that uses Zend_Db. I do however want to integrate a full ORM into the application to use it for more compl

Zend has Zend_Db but it's not a full ORM. I already have sections of an app written in a way that uses Zend_Db. I do however want to integrate a full ORM into the application to use it for more complex database operations, but I don't want to have to re-wr开发者_如何学Pythonite existing actions that are complete.

Those more experienced with Zend Framework, do you see a problem with using Zend_Db in some actions and an ORM in other actions? Is it possible for Zend_Db generated classes to co-exist with database classes generated by the ORM? What if I were to use both classes even in a single action? I don't see a conflict there but I'm not that great with MVC or ORM so I may be missing a big conflict.


I worked on Zend_Db quite a bit through the 1.0 release of ZF, and I've used Doctrine a little bit too.

There shouldn't be any conflict between Zend_Db and another ORM. However, objects fetched through the Zend_Db interface would have no knowledge of objects fetched through another ORM interface e.g. Doctrine, and vice versa.

So if your other ORM tried to be clever about batching commits to the database, you'd want to force it to commit before trying to load data from the same rows in a Zend_Db object. And likewise in reverse.

That said, there'd be nothing in either ORM-ish library that helps you manage these cases, so it's up to you to know how each ORM behaves. Sounds like you're setting yourself up for a lot of work to accommodate the leaky abstractions, and you'd be better off rewriting your existing Zend_Db code.

0

精彩评论

暂无评论...
验证码 换一张
取 消