Skip to Content (c) Skip to Navigation (n) Skip to Search (s)

1.0-beta (rev 75) released!

xPDO is in beta. There are several API improvements, more code reductions and simplifications, and the introduction of SQLite and PostgreSQL driver support are coming very soon. xPDO is being used to develop the next-generation MODx CMF.

Forgotten credits...

I'd like to extend a special thanks to Andrea Giammarchi for his PDO for PHP 4 implementation that inspired me to begin coding this project. If not for PHPClasses.org and the inspiration I found in Andrea's work there, the OpenExpedio project would likely not exist, as I probably would have invested my time in working with PHPDoctrine.

Getting the object back from the DB

Once the object is persisted to the database via a call to the object's save() method, you can now look up that instance in a number of ways.

By primary key

$person= $xpdo->getObject('Person', 1);

In this example, you are instantiating a persisted instance of the Person class which has a primary key with the value of 1.

By column values

I did add simple prepared statement abstraction to XPDO, so currently, to query objects by column values other than the primary key, you would use syntax like the following

$person= $xpdo->getObject('Person', array ('username' => 'boblabla');

By complex criteria

You can also construct platform optimized queries with complex business logic by creating an xPDOCriteria object representing a prepared statement.

$personTbl= $xpdo->getTableName('Person');
$criteria= new xPDOCriteria($xpdo, "SELECT p1.* FROM {$personTbl} p1 WHERE p1.username = :username AND EXISTS (SELECT 'x' FROM {$personTbl} p2 WHERE p2.id > 10 AND p2.id = p1.id)", array(':username' => 'boblabla'));
if ($person= $xpdo->getObject('Person', $criteria)) {
...
}