Doctrine vs. Propel: 2009 update


最高のPHP ORMライブラリ、
Doctrineおよび
Propel .
とくせい
DoctrineとPropelには、基本的なCRUD操作をサポートする基本的な特性があります.
どちらもモデルクラスを生成することができ、PropelはXMLに基づいて、DoctrineはYAMLに基づいている.
いずれも、存在するデータベースからそれぞれのプロファイルを生成することをサポートします.もちろん、100%正確ではありません.これは、一部のデータベース固有の特性の使用では適切な構成タグが生成されないためです.
高度な機能
両方は、ネストsetモデルを使用してツリー構造を格納することをサポートします.Doctrineのネストsetは、複数のツリーを1つのテーブルに格納することをサポートします.
両方ともモデルのデータ検証とモデル関係をサポートします.
They also support single table inheritance, although in Doctrine this is known as concrete inheritance. Doctrine supports two other inheritance models: Simple, where all classes have the same columns, and column aggregation, which stores an additional type value in the table, allowing automatic instanciation of the correct model type when querying.
And here ends the shared features. All of the following things are features that only Doctrine has.
Behaviors: Doctrine supports applying various “behaviors” to your models, for example a Timestampable model automatically gets two columns: created_at and updated_at, which get a time when a row is first created and when it’s updated respectively.
検索:Doctrineには全文検索エンジンがあります.
Data fixtures and migrations. Caching, events, pagination, command line interface… you might say that Doctrine beats Propel hands down when it comes to more advanced features.
使いやすさ
ドキュメント
The first thing is of course the documentation. Without decent documentation it’ll be difficult to use any library. Last year, Propel’s documentation was one of the main problems with it - and it still hasn’t gotten any better.
On the opposing side, the Doctrine team has been constantly improving their already superior documentation, and they are even working on a paperback Doctrine book. Documentation is a clear win for Doctrine.
ライブラリの使用
The first task you will have with both of the libraries is creating the model classes. Doctrine allows you to write simple YAML markup, or straight PHP code if you prefer it that way. If you use YAML, Doctrine has some methods that you can call in your own code, or you can download a command-line interface for building your models.
Propel’s approach to creating models requires you to write XML. To build your models from XML, you also need Phing. Personally I find XML more complex to write by hand than YAML, and requiring additional libraries is a bit of a hassle, unless you already use Phing for something else such as build automation.
データベース操作
Basic CRUD operations are quite similar in both. However, there’s a big difference in the way more precise queries are done.
Propel uses a criteria/peer approach:

$c = new Criteria();
$c->add(ExamplePeer::ID, 20);
//SELECT all "Example" models which have 20 as their ID and join all foreign tables.
$items = ExamplePeer::doSelectJoinFoobar($c);

2010年Propel 1.5の新しいAPIは使いやすいです
<?php
$book = BookQuery::create()->findPK(123); // retrieve a record from a database
$book->setName('Don\'t be Hax0red!'); // modify. Don't worry about escaping
$book->save(); // persist the modification to the database

$books = BookQuery::create()  // retrieve all books...
  ->filterByPublishYear(2009) // ... published in 2009
  ->orderByTitle()            // ... ordered by title
  ->joinWith('Book.Author')   // ... with their author
  ->find();
foreach($books as $book) {
  echo  $book->getAuthor()->getFullName();
}

Doctrine’s approach is to use Doctrine_Query and a custom SQL dialect, DQL:
$items = Doctrine_Query::create()
       ->from('Example e')
       ->leftJoin('e.Foobar')
       ->where('e.id = ?', 20)
       ->execute();

I think Doctrine’s approach lends itself better to the purprose. The code is also easier to read, as it flows more naturally. Propel’s version does take a bit less code.
Setting values on model classes is also a bit different: Doctrine uses magic properties, while Propel generates methods for setting and getting values. This gives Propel code the advantage of autocompletion in more IDE’s - as far as I know, only the latest versions of NetBeans can autocomplete Doctrine’s magic properties, thanks to their support of the @property PHPDoc annotation.
Conclusion
それをどう見てもDoctrineはもっと良くて、そのもっと良いドキュメント、もっと良い特性、コミュニティはもっと活発です.Propelは進歩していますが、Doctrineはもっと進歩しています.
良い人がオーム・ヴィジュアル・エディターをしました
http://www.orm-designer.com/はプロジェクトで使用できます.