Kinda hidden in the site, it’s labeled ’wiki’ on the site’s links, not ’docs’.
http://rtfm.modx.com/display/xPDO20/Getting+Started
To get rolling using xPDO as a standalone w/o Modx, you will have to first generate your classes that model your database (one time deal for steps 1-3):
1. generate the xml schemas from the db. (assumes your db is prefixed with ’mydb_’)
include_once ('/xpdo/xpdo.class.php');
$xpdo= new xPDO('mysql:host=localhost;dbname=myolddatabase','username','password','mydb_');
$manager= $xpdo->getManager();
$generator= $manager->getGenerator();
$xml= $generator->writeSchema('/path/to/my/new/directory_name.schema.xml','directory_name', 'xPDOObject','mydb_');
2. Add in the table relations to your xml schemas by hand:
http://rtfm.modx.com/display/xPDO20/Defining+Relationships
3. Next, generate the php classes from the schemas + relationships
$schema = '/path/to/my/new/directory_name.schema.xml';
$target = '/path/to/directory/holding/my/generated/db/classes/';
$generator->parseSchema($schema,$target);
Its all detailed here:
http://rtfm.modx.com/display/xPDO20/Creating+a+Model+With+xPDO
--------------
Then, to use the classes youve generated above, do something like this (sample snagged from: core/model/schema/build.modx.php):
Here’s the main class to include: xpdo\xpdo.class.php
include_once ('/xpdo/xpdo.class.php');
//Set some valid connection properties here
$xpdo= new xPDO( DSN, DB_USER, DB_PASS, XPDO_TABLE_PREFIX,
array (
PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING,
PDO::ATTR_PERSISTENT => false,
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true
)
);
// set path to your classes directory
$xpdo->setPackage('modx', dirname(XPDO_CORE_PATH) . '/model/');
$xpdo->setDebug(true);
// do your crud activities here
About the only non obvious line in there is the ’$xpdo setpackage’ call. A more obvious, but less concise, name for that might be ’SetDirectoryOfDbClassesLocation’:
$xpdo->setPackage(directory_name_holding_generated_db_classes, path_to_parent_directory);
Hope that gets you started.