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
I work on miniOrm. Just a mini ORM, for using Object Model & MySQL Abstraction Layer as simply as possible. Hope it may help you : http://jelnivo.fr/miniOrm/
NOTE: This answer was originally posted at StackOverflow.com by Cédric Mouleyre
- Catherine answered 11 years ago
- You must login to post comments
include "NotORM.php";
$pdo = new PDO("mysql:dbname=software");
$db = new NotORM($pdo);
$applications = $db->application()
->select("id, title")
->where("web LIKE ?", "http://%")
->order("title")
->limit(10)
;
foreach ($applications as $id => $application) {
echo "$application[title]\n";
}
NOTE: This answer was originally posted at StackOverflow.com by Charlie Chai
- Anne answered 12 years ago
- last edited 12 years ago
- You must login to post comments
MicroMVC has a 13 KB ORM that only relies on a 8 KB database class. It also returns all results as ORM objects themselves and uses late static binding to avoid embedding information about the current object’s table and meta data into each object. This results in the cheapest ORM overhead there is.
It works with MySQL, PostgreSQL, and SQLite.
NOTE: This answer was originally posted at StackOverflow.com by Xeoncross
- Rick answered 12 years ago
- last edited 12 years ago
- You must login to post comments
Have a look at the LEAP ORM for Kohana. It works with a bunch of databases, including DB2, Drizzle, Firebird, MariaDB, SQL Server, MySQL, Oracle, PostgreSQL, and SQLite. With a simple autoload function, it can work with almost any PHP framework. The source code is on GitHub at https://github.com/spadefoot/kohana-orm-leap. You can checkout LEAP’s tutorials online.
The ORM library works with non-integer primary keys and composite keys. Connections are managed via a database connection pool and it works with raw SQL queries. The ORM even has a query builder that makes building SQL statements super simple.
NOTE: This answer was originally posted at StackOverflow.com by Matthew
- Rebecca answered 12 years ago
- last edited 12 years ago
- You must login to post comments
Agile Toolkit has its own unique implementation of ORM/ActiveRecord and dynamic SQL.
Introduction: http://agiletoolkit.org/intro/1
Syntax (Active Record):
$emp=$this->add('Model_Employee');
$emp['name']='John';
$emp['salary']=500;
$emp->save();
Syntax (Dynamic SQL):
$result = $emp->count()->where('salary','>',400)->getOne();
While Dynamic SQL and Active Record/ORM is usable directly, Agile Toolkit further integrates them with User Interface and jQuery UI. This is similar to JSF but written in pure PHP.
$this->add('CRUD')->setModel('Employee');
This will display AJAXified CRUD with for Employee model.
NOTE: This answer was originally posted at StackOverflow.com by romaninsh
- Laurie answered 12 years ago
- last edited 12 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 12 years ago
- last edited 12 years ago
- You must login to post comments
Brazilian ORM: http://www.hufersil.com.br/lumine. It works with PHP 5.2+. In my opinion, it is the best choice for Portuguese and Brazilian people, because it has easy-to-understand documentation and a lot of examples for download.
NOTE: This answer was originally posted at StackOverflow.com by Paulo Araujo
- Diana answered 13 years ago
- last edited 12 years ago
- You must login to post comments
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.
NOTE: This answer was originally posted at StackOverflow.com by Sander Marechal
- Glenn answered 13 years ago
-
من به یک پاسخ جواب میدهم
- You must login to post comments
If you are looking for an ORM that implements the Data Mapper paradigm rather than Active Record specifically, then I would strongly suggest that you take a look at GacelaPHP.
Gacela features:
- Data mapper
- Foreign key mapping
- Association mapping
- Dependent mapping
- Concrete table inheritance
- Query object
- Metadata mapping
- Lazy & eager loading
- Full Memcached support
Other ORM solutions are too bloated or have burdensome limitations when developing anything remotely complicated. Gacela resolves the limitations of the active record approach by implementing the Data Mapper Pattern while keeping bloat to a minimum by using PDO for all interactions with the database and Memcached.
NOTE: This answer was originally posted at StackOverflow.com by Noah Goodrich
- Michelle answered 13 years ago
- last edited 12 years ago
- You must login to post comments
Sado is a simple PHP ORM package, easy to use, and offers video tutorials
NOTE: This answer was originally posted at StackOverflow.com by Shay Anderson
- Joe answered 13 years ago
- last edited 12 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 13 years ago
- You must login to post comments
Try PdoMap. Wikipedia claims that is inspired by Hibernate. Since I never used Hibernate, I cannot judge :), but I would say from my experience that is good and fast ORM that is easy to implement, with a less steep learning curve that other ORMs.
NOTE: This answer was originally posted at StackOverflow.com by aromawebdesign.com
- Keith answered 13 years ago
- last edited 12 years ago
- You must login to post comments
Looked at Syrius ORM. It’s a new ORM, the project was in a development stage, but in the next mouth it will be released in a 1.0 version.
NOTE: This answer was originally posted at StackOverflow.com by biancardi
- Dawn answered 13 years ago
- last edited 12 years ago
- You must login to post comments
A really good simple ORM is MyActiveRecord. MyActiveRecord documentation. I have been using it a lot and can say it’s very simple and well tested.
NOTE: This answer was originally posted at StackOverflow.com by Szymon Wygnański
- Jeffery answered 13 years ago
- last edited 12 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 13 years ago
- You must login to post comments
Tried the ORM of Flourish library.
NOTE: This answer was originally posted at StackOverflow.com by eaguilar
- Willie answered 14 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 12 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 12 years ago
- You must login to post comments
Try Doctrine2. It’s probably the most powerful ORM tool for PHP. I’m mentioning it separately from Doctrine 1, because it’s a completely different piece of software. It’s been rewritten from scratch, is still in beta phase, but it’s usable now and developed.
It’s a very complex ORM, but well designed. Lot of magic from original Doctrine 1 disappeared. It provides a complete solution, and you can write your own ORM on top of Doctrine2 or use just one of its layers.
NOTE: This answer was originally posted at StackOverflow.com by tomp
- Chris answered 14 years ago
- last edited 12 years ago
- You must login to post comments
There’s a fantastic ORM included in the QCubed framework; it’s based on code generation and scaffolding. Unlike the ActiveRecord that’s based on reflection and is generally slow, code generation makes skeleton classes for you based on the database and lets you customize them afterward. It works like a charm.
NOTE: This answer was originally posted at StackOverflow.com by Alex Weinstein
- Ralph answered 14 years ago
- last edited 12 years ago
-
this resembles the way yii works
NOTE: This comment was originally posted at StackOverflow.com by sivann
- You must login to post comments