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.
NOTE: This question was originally posted at StackOverflow.com by sgibbons
- Wayne asked 16 years ago
- last edited 12 years ago
- You must login to post comments
Try RedBean, its requires:
- No configuration
- No database (it creates everything on the fly)
- No models
- etc.
It even does all the locking and transactions for you and monitors performance in the background. (Heck! it even does garbage collection….) Best of all… you don’t have to write a single… line of code… Jesus this, ORM layer, saved me ass!
NOTE: This answer was originally posted at StackOverflow.com by winterswk
- Sherry answered 16 years ago
- last edited 13 years ago
-
+1 +1 +1 +! +! !!!!...jesus I read the first part of the documentation and it got me making sinister dictator laughter, and I'm downloading it already!
NOTE: This comment was originally posted at StackOverflow.com by Kim Jong Woo
-
I'm not a PHP guy, but I have to admit that looks pretty slick.
NOTE: This comment was originally posted at StackOverflow.com by Chris Lively
-
I really don't want to be a downer, but this goes against everything I know -- that database tables should be designed with care (for performance) and that
ALTER TABLE
calls are expensive (and potentially dangerous).NOTE: This comment was originally posted at StackOverflow.com by NickC
-
@NickC Once you are finished developing the database can be 'frozen' to stop any more changes.
NOTE: This comment was originally posted at StackOverflow.com by Sam
- You must login to post comments
There are only two good ones: Doctrine and Propel. We favor Doctrine, and it works well with Symfony. However if you’re looking for database support besides the main ones you’ll have to write your own code.
NOTE: This answer was originally posted at StackOverflow.com by Ilya Kochetov
- Jon answered 16 years ago
- last edited 13 years ago
- You must login to post comments
Another great open source PHP ORM that we use is PHPSmartDb. It is stable and makes your code more secure and clean. The database functionality within it is hands down the easiest I have ever used with PHP 5.3.
NOTE: This answer was originally posted at StackOverflow.com by Joe
- Donna answered 14 years ago
- You must login to post comments
Look at http://code.google.com/p/lworm/ . It is a really simple, but powerful, lightweight ORM system for PHP. You can also easily extend it, if you want.
NOTE: This answer was originally posted at StackOverflow.com by Faz
- Cindy answered 14 years ago
- You must login to post comments
PHP ORM Faces For PDO extension. See PHP Faces Framework.
$urun = new Product();
$urun->name='CPU'
$urun->prince='124';
$urun->save();
NOTE: This answer was originally posted at StackOverflow.com by Kurt
- Robert answered 15 years ago
- last edited 12 years ago
- You must login to post comments
I found ORM related classes in the PHP library Flourish.
NOTE: This answer was originally posted at StackOverflow.com by VDVLeon
- Linda answered 14 years ago
- last edited 13 years ago
- You must login to post comments
Doctrine is probably your best bet. Prior to Doctrine, DB_DataObject was essentially the only other utility that was open sourced.
NOTE: This answer was originally posted at StackOverflow.com by anon
- Sherry answered 16 years ago
- last edited 13 years ago
- You must login to post comments
Look into Doctrine.
Doctrine 1.2 implements Active Record. Doctrine 2+ is a DataMapper ORM.
Also, check out Xyster. It’s based on the Data Mapper pattern.
Also, take a look at DataMapper vs. Active Record.
NOTE: This answer was originally posted at StackOverflow.com by Ian P
- Greg answered 16 years ago
- last edited 13 years ago
- You must login to post comments
You should check out Idiorm and Paris.
NOTE: This answer was originally posted at StackOverflow.com by th3mus1cman
- Suzanne answered 13 years ago
- last edited 13 years ago
- You must login to post comments
Axon ORM is part of the Fat-Free Framework – it features an on-the-fly mapper. No code generators. No stupid XML/YAML configuration files. It reads the database schema directly from the backend, so in most CRUD operations you don’t even have to extend a base model. It works with all major PDO-supported database engines: MySQL, SQLite, SQL Server/Sybase, Oracle, PostgreSQL, etc.
/* SQL */
CREATE TABLE products (
product_id INTEGER,
description VARCHAR(128),
PRIMARY KEY (product_id)
);
/* PHP */
// Create
$product=new Axon('products'); // Automatically reads the above schema
$product->product_id=123;
$product->description='Sofa bed';
$product->save(); // ORM knows it's a new record
// Retrieve
$product->load('product_id=123');
echo $product->description;
// Update
$product->description='A better sofa bed';
$product->save(); // ORM knows it's an existing record
// Delete
$product->erase();
Most of all, the plug-in and accompanying SQL data access layer are just as lightweight as the framework: 14 KB (Axon) + 6 KB (SQLdb). Fat-Free is just 55 KB.
NOTE: This answer was originally posted at StackOverflow.com by stillstanding
- Wayne answered 14 years ago
- last edited 13 years ago
- You must login to post comments