为什么我应该使用 Doctrine 而不是 Zend_Db?
我在一些项目中使用Zend_Db,我发现Doctrine有一段时间但从未真正使用过它。
Doctrine 相对于 Zend_Db 有什么优势?使用 Doctrine 有什么好处?
顺便问一下,在 Zend Framework 1.10.7 中使用 Doctrine 方便吗?与其他组件集成和使用?因为似乎不存在 Doctrine Adapter
谢谢
I use Zend_Db in some project, I discover Doctrine there is a while but never actually used it.
What are the advantage of Doctrine over Zend_Db ? What are the benefits to use Doctrine ?
By the way, is it easy to use Doctrine with Zend Framework 1.10.7? Integration and use with the other component ? As it doesn't seem to exist a Doctrine Adapter
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Doctrine 是一个 ORM。它旨在将丰富的域对象模型持久保存到数据库中,并允许有效查询,同时将结果维护为对象。 Zend_Db 包含表和行数据网关设计模式的实现,它提供了查询单个表和操作其行的简单方案。这使得 Zend_Db 成为 Doctrine 的近亲,后者更加强大和有用,同时也更加复杂和资源密集。如果您有一个具有大量相互关系的丰富领域模型,那么 Doctrine 是您管理所有复杂性的解决方案。对于简单表上的简单 CRUD,请务必使用 Zend_Db。
您不需要 Doctrine 适配器,只需使用它即可。不过,Zend Framework 中的几个类很容易与 Zend_Db 集成 - 例如基于数据库行存在的验证 - 并且您必须编写自己的等效类。这将需要一些工作,但这不是一项复杂的任务,您也许可以在网上找到一些现成的实现。
Doctrine is an ORM. It's meant for persisting a rich domain object model to a database and allow querying effectively while maintaining the results as objects. Zend_Db comprises an implementation of the table and row data gateway design patterns, which provide a simple scheme for querying a single table and manipulating its rows. That makes Zend_Db a kind of a lesser cousin of Doctrine, with the latter vastly more powerful and useful while also more complex and resource intensive. If you have a rich domain model with a lot of interrelations, Doctrine is your solution to managing all the complexity. For simple CRUD on simple tables, by all means go for Zend_Db.
You don't need an adapter for Doctrine, you just use it. Several classes in Zend Framework integrate readily with Zend_Db, though - such as validation based on database row existence - and you'll have to cook up your own equivalents. It will take some work but it's not a complex task, and you may be able to find some implementations readily available on the net.