The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Php Orm

Just wanted to start a thread to list all the available PHP ORM solutions.

There are a few threads which all almost the same and have links to available solutions, but they're all over the place. Much like the list of templating engines a while back, this will be focusing on PHP (4 and 5) ORM solutions.

Metastorage (?)EZPDO (PHP5)Propel (PHP5) [Uses Creole]
Changes (By Marcus) [Marcus, did you have it available on a site I could link to?]
PHP5 port of Changes [A release sometime soon, working on better PgSQL support and touching up the current MySQL. It uses PDO]

The features vary greatly for each product. There is quite alot of difference.

Perhaps some industrious person could build a feature matrix to compare them. Actually, if a person knowledgable about each could post its features perhaps we could probably build a basic feature matrix from that.

Here is what some of the projects list as their features:

Metastorage features
* Easy to write and understand component model definition format in XML
* Automatic generation of (database) schema for the persistence container
* Automatic generation of all classes: data classes, factory class and (database) schema installation class
* All code is generated without the need for the developer to write SQL code manually
* A powerful Object Query language lets the developer specify arbitrary search conditions with the same level of complexity as with SQL.
The object queries are pre-compiled and embedded in the generated code to maximize the query execution performance.
* The generated code is very compact. Metastorage performs extensive analysis to only include code that will be actually used according to the type of operations that the developer wants the generated classes to execute.
* The generated code is self-contained and so it does not depend on MetaL or libraries of code that are not supplied
* Generation of classes to create, validate and process Web forms to manage objects of the data classes.
* Automatic generation of Entity-Relationship graphs in UML of the component class diagram

Propel Features
* Easily extensible. Use of XML schemas makes it possible to easily integrate with other components driven by your data model (e.g. a form generation tool could also use the same XML schema) or to extend the schema definition to include attributes for other components (e.g. more validation informat for that form tool).
* Easily customizable. The generated object model is built to be customized. All internal calls are made to empty stub classes which extend the classes with generated logic. You can override behavior in the stub classes or provide your own custom business logic without sacrificing the ability to rebuild your object model at a later time.
* Plays nice. This is a way of saying that Propel doesn't force you to use only Propel tools. For example, while you can use the Criteria objects to construct queries without writing SQL, we recognize that Criteria doesn't do everything and so we've also made it easy to use custom SQL to populate generated objects.
* Truly independent. The use of a build process to create customized SQL and PHP classes means that your database interactions with Propel are truly database-independent -- taking advantage of the strenghts of your RDBMS and providing emulation for things your RDBMS doesn't support (e.g. fkey cascading deletes in MySQL). Tools are also provided to easily move data from one RDBMS to another.
* Intuitive, Predictable. Propel's data model definition is follows very closely the structure of the underlying database. This provides the advantage of making Propel easy to understand and also of behaving predictably with very complex data models.
* Advanced. Propel makes the difficult relational problems easy and efficient. For example, Propel provides the ability to populate related (foreign key) objects from a single query. Propel also supports basic (table per class tree) inheritance and other advanced OO features.

DB_DataObject
* Build SQL and execute statements based on the objects variables.
* Group source code around the data that they relate to.
* Provide a simple consistent API to access and manipulate that data.
* A common simple configuration method (for setting database connections)
* A fast and simple store for database descriptions, so primary keys can be used to locate data quickly
* a debugger that enables you to see what exactly it is doing.
* basic data validation - so the strings and integers can be checked.
* Posibility to build complex joins or get related data by secondary calls (links) .
* Ability to create and update your Table specific classes with the current database table variables (see autobuilding)
* Simple to integrate with other packages, with setFrom() and toArray() methods

* All entities mapped to the same database tables: 1 for storing information about the class, 1 for storing all the properties of the class (this has since been broken down into a database table to map to each property type, which is all handled internally).
* Automatically generated editing interfaces for view, edit and administration actions (easy to customise views)
* Simple API for creating, saving, loading and relating entities (no SQL needed)

// Load the author into a new object
$reloadedAuthor = ClassManager::loadObjectById($author->objectId(), 'rw');
* *nix based permission system allowing for user group and world permissions to be set
* Simple but powerful methods for querying and finding entities
* Tree structure provides recognizable heirachical view of entities
* MySQL and SQLite support
* Predefined entity types.

Well the thread is still open. So if the authors of some of these projects or the users would be able to write up a single post one basic use and overall comfort it would be great. Most likely users should be doing the reviewing to make sure there is no bias.

Just amazed at how many there are. Good way to save time by implementing ideas from each other. And even better that they're spread between PHP4 and PHP5.

Thanks for initiating the thread and the idea of starting a wiki. That will be really helpful for the users. I would be happy to help out with the EZPDO materials. We have just summarized the latest improvements and plans before the official 1.0 release in the coming month.

Thanks for initiating the thread and the idea of starting a wiki. That will be really helpful for the users. I would be happy to help out with the EZPDO materials. We have just summarized the latest improvements and plans before the official 1.0 release in the coming month.

If you could you can document bits of your app over on the wiki, just create a page for EZPDO and put a link next to it on the ORM page. Also head to http://wiki.cc/php/Documentation and add a link to your page there if you could.

Hi,
I looking for an object persistance product for a project I'm working on. I cheked all of the software mentionned above and Propel seems the more appealing. However, it looks like it does not handle inheritance very well as it requires all the fields of the sub classes to be in the table for the base classe (even if the base class doesn't need them).

Basically, we have a "Server" class which should be mapped to a "servers" table and which has some properties. Then we have a "LinuxServer" class which inherit from the "Server" class. I'm looking for a product that would allow me to have a "servers" table containing all the properties of the "Server" class and a "linux_servers" table which would contain only the properties of "LinuxServer" which are not covered by the "server" table.

Does any of the above mentionned products fullfills this requirement ?

it seems to be a problem with all the currently available orm-api's for php that they are table-centric, and thus doesn't hande inheritance very well. i'm not sure, but i think that ezpdo may be supporting this kind of mapping. anybody who can verify this ?

it seems to be a problem with all the currently available orm-api's for php that they are table-centric, and thus doesn't hande inheritance very well. i'm not sure, but i think that ezpdo may be supporting this kind of mapping. anybody who can verify this ?

EzPdo doesnt support this. Ive never come across any php ORM's that support any of the inheritance mapping patterns.

EDIT:
Actually Perdure (see signature) probably supports this. Perdure on a whole may be too immature to use in a production environment at this time though. The only QA it has had is the tests.

Thanks all for your replies. Could you please explain a bit how to do it with ezpdo with exclude_superclass? Thanks.

illogix, this is something we'd like to have in the future release (post 1.x as i indicated in my reply). not implemented yet. keep bugging us if you want it badly so we may be able to adjust our priorities.

back to your problem. not sure how important it is for you to avoid mapping the superclass. for now, if you use EZPDO, the only cost of not excluding the parent class is some wasted columns in the table. not optimal in terms of storage efficiency, but perhaps it doesn't matter much if you are not dealing with large tables (that have many columns).

Propel ORM

Hi everyone, i am a student of information Systems and i would like to know
how to use propel to model many to many relationships.furthermore
i need sample codes to be able to know how to retrieve from propel...
i have a database consits of persons and images table which are all related to each other or some are related to a specific number of people in the table...

i want to retrieve all people even indirectly related to say person x..
and person x is related to P2 and p2 to p3 and so on.so i need to retrieve all
these persons.in the above scenario person p3 is indirectly related to x,the query should also not neglect the other related persons...

can such a complex query be done in propel.....
if so could someone help me out please........

help on installing propel under windows

i would like to know how to configure and install propel under windows xp....
am using wamp also to run php scripts....so anyone can help me out please how to merge propel and wamp.....i had a look at bthe guide am a bit lost coz am a newbie in linux....