沃梦达 / 编程问答 / php问题 / 正文

PHP ORM:Doctrine vs. Propel

PHP ORMs: Doctrine vs. Propel(PHP ORM:Doctrine vs. Propel)

本文介绍了PHP ORM:Doctrine vs. Propel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 symfony 开始一个新项目,它很容易与 Doctrine 和 推进a>,但我当然需要做出选择....

非常感谢.

感谢所有回复,有用的东西.这个问题没有真正正确的答案,所以我只会将获得最多票数的答案标记为已批准.

解决方案

我会选择 Doctrine.在我看来,这是一个更加活跃的项目,并且作为 symfony 的默认 ORM,它得到了更好的支持(尽管官方认为 ORM 是平等的).

此外,我更喜欢您使用查询的方式(DQL 而不是 Criteria):

add(ExamplePeer::ID, 20);$items = ExamplePeer::doSelectJoinFoobar($c);//教义$items = Doctrine_Query::create()->from('示例 e')->leftJoin('e.Foobar')->where('e.id = ?', 20)->执行();?>

(Doctrine 的实现对我来说更直观).

另外,我真的更喜欢你在 Doctrine 中管理关系的方式.

我认为 Doctrine 文档中的这一页值得一读:http://www.doctrine-project.org/documentation/manual/1_2/en/introduction:doctrine-explained

总结一下:如果我要开始一个新项目,或者必须在学习 Doctrine 和 Propel 之间做出选择,我会随时选择 Doctrine.

I'm starting a new project with symfony which is readily integrated with Doctrine and Propel, but I of course need to make a choice.... I was wondering if more experienced people out there have general pros and/or cons for going with either of these two?

Thanks a lot.

EDIT: Thanks for the all the responses, useful stuff. There's no truly correct answer to this question so I'll just mark as approved the one that got the most popular up-votes.

解决方案

I'd go with Doctrine. It seems to me that it is a much more active project and being the default ORM for symfony it is better supported (even though officially the ORMs are considered equal).

Furthermore I better like the way you work with queries (DQL instead of Criteria):

<?php
// Propel
$c = new Criteria();
$c->add(ExamplePeer::ID, 20);
$items = ExamplePeer::doSelectJoinFoobar($c);

// Doctrine
$items = Doctrine_Query::create()
       ->from('Example e')
       ->leftJoin('e.Foobar')
       ->where('e.id = ?', 20)
       ->execute();
?>

(Doctrine's implementation is much more intuitive to me).

Also, I really prefer the way you manage relations in Doctrine.

I think this page from the Doctrine documentation is worth a read: http://www.doctrine-project.org/documentation/manual/1_2/en/introduction:doctrine-explained

To sum up: If I were starting a new project or had to choose between learning Doctrine and Propel I'd go for Doctrine any day.

这篇关于PHP ORM:Doctrine vs. Propel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:PHP ORM:Doctrine vs. Propel

基础教程推荐