Good PHP ORM Library?

2018-12-31 01:34发布

Is there a good object-relational-mapping library for PHP?

I know of PDO/ADO, but they seem to only provide abstraction of differences between database vendors not an actual mapping between the domain model and the relational model. I'm looking for a PHP library that functions similarly to the way Hibernate does for Java and NHibernate does for .NET.

标签: php database orm
30条回答
ら面具成の殇う
2楼-- · 2018-12-31 01:39

I really like Propel, here you can get an overview, the documentation is pretty good, and you can get it through PEAR or SVN.

You only need a working PHP5 install, and Phing to start generating classes.

查看更多
残风、尘缘若梦
3楼-- · 2018-12-31 01:41

Give a shot to dORM, an object relational mapper for PHP 5. It supports all kinds of relationships (1-to-1), (1-to-many), (many-to-many) and data types. It is completely unobtrusive: no code generation or class extending required. In my opinion it is superior to any ORM out there, Doctrine and Propel included. However, it is still in beta and might change significantly in the next couple months. http://www.getdorm.com

It also has a very small learning curve. The three main methods you will use are:

<?php 
$object = $dorm->getClassName('id_here');
$dorm->save($object);
$dorm->delete($object);
查看更多
几人难应
4楼-- · 2018-12-31 01:42

Try PHP ADOdb.

I can't say it's the best, because I haven't used the others. But it's fast, it supports Memcached and caching.

And it's waaaay faster than Zend Framework's DB/Select.

查看更多
零度萤火
5楼-- · 2018-12-31 01:42

Doctrine is probably your best bet. Prior to Doctrine, DB_DataObject was essentially the only other utility that was open sourced.

查看更多
其实,你不懂
6楼-- · 2018-12-31 01:43

I have had great experiences with Idiorm and Paris. Idiorm is a small, simple ORM library. Paris is an equally simple Active Record implementation built on Idiorm. It's for PHP 5.2+ with PDO. It's perfect if you want something simple that you can just drop into an existing application.

查看更多
人气声优
7楼-- · 2018-12-31 01:43

You can check out Repose if you are feeling adventurous. Like Outlet, it is modeled after Hibernate.

It is still very early in its development, but so far the only restrictions on the domain model are that the classes are not marked final and properties are not marked private. Once I get into the land of PHP >= 5.3, I'll try to implement support for private properties as well.

查看更多
登录 后发表回答