We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6500
    • 1 Posts
    Hi everybody,

    I’ve got a PHP 5 project that uses some ORM to access a MySQL database.
    I need to rewrite it for PHP 4, so I’m looking for a PHP 4 compatible ORM solution.
    I’m trying to use xPDO, but the documentation is very light (some pages are empty, ie http://xpdo.org/documentation/migration-guides.html)

    I managed to create a test class and map for one table in my DB, with which I can insert data and retrieve data by field name.

    But I still have some questions :
    - how can I specify the primary key for my table ? (it seems that I can’t delete a row without a PK)
    - how can I retrieve a set of rows ? (getObject() only returns one row)

    I didn’t see anything about these subjects nowhere undecided

    Thanks a lot smiley
    • @Danny - There are not (yet) many developers working on xPDO other than myself and with my obligations to MODx, xPDO, and my day job, the documentation has yet to be fully fleshed out. I’ll do my best to guide you and perhaps this will help produce some good content for the documentation.

      Quote from: Danny at Jan 10, 2008, 02:55 PM

      - how can I specify the primary key for my table ? (it seems that I can’t delete a row without a PK)
      Did you create an XML schema of your model using the reverse-engineering facilities or manually? There is not a lot of documentation on that, but you can see a great example of a schema at http://svn.xpdo.org/crucible/browse/~raw,r=38/xpdo/trunk/model/schema/sample.mysql.schema.xml, or a more advanced one is available at http://svn.modxcms.com/crucible/browse/~raw,r=3272/MODx/branches/0.9.7/core/model/schema/modx.mysql.schema.xml.

      Regardless, you can easily specify the pk with the attribute index="pk", though you’ll also want to use generated="native" to indicate that you want to use a MySQL auto-increment key. If your object extends xPDOSimpleObject, you already have a pk column with the fieldname of id.

      Quote from: Danny at Jan 10, 2008, 02:55 PM

      - how can I retrieve a set of rows ? (getObject() only returns one row)
      You use xPDO::getCollection() or xPDO::getCollectionGraph() to return row collections. xPDO::getObject() and xPDO::getObjectGraph() are used for returning a single row only.