是否值得使用教条2与Zend框架? [英] Is it worth using Doctrine 2 with Zend Framework?

查看:125
本文介绍了是否值得使用教条2与Zend框架?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道一些用户在Zend Framework中使用了Doctrine 2而不是Zend_Db。但我不知道为什么为什么Doctrine2比Zend_Db好,为什么Zend_Db不好?

I know that some users use Doctrine 2 instead of Zend_Db in Zend Framework. But I don't know why. Why is Doctrine2 better than Zend_Db and why Zend_Db is not good?

谢谢

推荐答案

(2013年3月7日)免责声明:这个答案现在可能已经过时了。目前我并没有跟上PHP社区,而是在Doctrine ORM v2和Zend Framework v1之间进行了比较。这是一个苹果与橘子的比较,因为它们是两个不同的东西。

(7-Mar-2013) Disclaimer: This answer is probably now a bit out of date. I'm not keeping up with the PHP community at the moment and this comparison is between Doctrine ORM v2 and Zend Framework v1. This is an apples vs. oranges comparison because they're two different things.

开箱即用的Zend_Db更多的只是PDO之上的增强型数据库抽象层,其中Doctrine 2是一个对象关系映射器(它位于它自己的DBAL之上)。

Out-of-the-box Zend_Db is more just an enhanced Database Abstraction Layer on top of PDO, where as Doctrine 2 is a Object Relational Mapper (which sits on top of it's own DBAL).

Doctrine 2对于更复杂的域层来说更好,因为所有的业务逻辑,持久性逻辑等都是通过多个类分隔的,所以它们不服务于多个角色。另外,因为你有更多的课堂 - 比较干净和松散耦合 - 它使测试更容易。

Doctrine 2 is much better for more complicated domain layers, because all your business logic, persistence logic, etc are separated over multiple classes, so they don't serve multiple roles. Also, because you have more classes - that are cleaner and loosely-coupled - it makes testing them much easier.

此外,您将只写入您使用Zend_Db的SQL的一小部分,因为您可以操纵您的实体对象,而Doctrine将这些更改转换为数据库。生成的SQL还利用了可以让您获得不错的性能增益的交易!

Futhermore, you'll be writing only fraction of the SQL that you be using Zend_Db, because you can manipulate your entity objects and Doctrine translates those change to the database. The generated SQL also takes advantage of transactions which gives you a decent performance gain!

我建议您阅读域驱动设计,以更好地了解为什么Doctrine 2真是太棒了。

I'd recommend you read up on Domain-Driven Design to get a better understanding of why Doctrine 2 is so awesome.

不要误会我,但是你可以用Zend_Db做DDD,但是并不是真的有OOTB(因为它不是ORM)不会像Doctrine 2那样强大和功能齐全。

Don't get me wrong though, you can do DDD with Zend_Db but it's not really there OOTB (because it's not an ORM), and wouldn't be nearly as powerful and full-featured like Doctrine 2.

这篇关于是否值得使用教条2与Zend框架?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆