Quote from: pwaring at May 10, 2010, 08:03 PM
1) Start with an existing MySQL database and generate the XML schema from this (using PhpMyAdmin or something)
2) Use the XML schema generated in 1) and any manual editing needed (and it would show how to manually edit it to add foreign key restraints etc or anything that can’t be done automatically) to generate the Php OO classes that map to the MySQL database
3) An example of how to update a table or insert into a table using the Objects generated in 2)
4) An example of how to use this from within ModX - i.e using a Snippet to update a table from an HTML form or such the like
Peter
Yeah the revo docs are a bit thin and scattered about at this point in the development. There is no end to end sample/tutorial yet (that I know of), although the "Writing a 3rd Party Component in MODx Revolution, Pt. I & II" gets ya about 3/4 of the way there. Revo is just an infant at the moment in terms of docs.

Im a bit of a newb myself (to both php & modx) and was looking for similar stuff as you are when I first got here, and have been slowly poking my nose around asking questions and reading as much as possible.
You sort of have to "pick and parse" through the example tuts + a few forum pots + the api docs to get all the pieces together at the moment. (Personally, I have to read & re-read it all a coupla times myself to grok it all down -- much of the modx terminology is pretty unique (I.e calling a ’webpage’ a ’resource’; a ’snippet’ an ’element’, etc, etc) I know what youre looking for is a defined "beginning" of where to start, where to place your own code in all this, and just make something happen. But I believe everything you want to do is very possible and is listed somewhere:
To answer your specific questions 1-4:
1. reverse engineering and generating the schema xml file from existing db:
http://svn.modxcms.com/docs/display/xPDO20/Creating+a+Model+With+xPDO & post #2 here by shamblett is pretty clear -->
http://modxcms.com/forums/index.php/topic,40174.msg242645.html#msg242645
(bear in mind that the generator doesn’t include table relations yet-- those are still hand added after
generation -- but there is a feature request in JIRA to have xpdo also fully reverse engineer the relationships too for innodb. Also in JIRA somewhere I saw an xsd or dtd to validate hand coded schema files was a feature request)
2. manually adding FK/relationships to schema xml file after you’ve generated:
http://svn.modxcms.com/docs/display/xPDO20/Defining+Relationships &
http://svn.modxcms.com/docs/display/revolution/xPDO+XML+Schema+File+vs.+Table+Structure+Examples
2.5 generate the custom OO modx classes:
http://svn.modxcms.com/docs/display/xPDO20/Generating+the+Model+Code & second post here by netprophet-->
http://modxcms.com/forums/index.php/topic,48729.msg285108.html#msg285108 (keep in mind here that you would ordinarily only generate your tables/schema/objects one time when you load or ’build’ them into modx --- so most of these links & code will also mention "packages" and "transports" which is the modx mechanism to move/build/load custom code into modx from zip files.)
3. using the xpdo objects you generated from the xml files:
http://svn.modxcms.com/docs/display/xPDO20/Using+Your+xPDO+Model &
http://svn.modxcms.com/docs/display/xPDO20/Creating+Objects & (splitting red shows a simple instance of the package/objects in this thread in post #4 -->
http://modxcms.com/forums/index.php/topic,41690.msg250721.html#msg250721
4. here’s some samples of setting fields and saving db rows with your custom objects/classes:
starts here -->
http://svn.modxcms.com/docs/display/xPDO20/Creating+Objects & continues here -->
http://svn.modxcms.com/docs/display/xPDO20/Setting+Object+Fields & also how to query for your objects here -->
http://svn.modxcms.com/docs/display/xPDO20/Retrieving+Objects how to delete your objects here (remove rows from db) -->
http://svn.modxcms.com/docs/display/xPDO20/Removing+Objects & working with your Fk/relationship objects -->
http://svn.modxcms.com/docs/display/xPDO20/Working+with+Related+Objects
What I did for my first modx attempt was not to create my own code, but I replicated the "Writing a 3rd Party Component in MODx Revolution, Pt. I & II" (
http://svn.modxcms.com/docs/display/~splittingred/2008/06/26/Writing+a+3rd+Party+Component+in+MODx+Revolution%2C+Pt.+I &
http://svn.modxcms.com/docs/display/~splittingred/2008/06/26/Writing+a+3rd+Party+Component+in+MODx+Revolution%2C+Pt.+II) tutorial from start to finish to just get a grasp on where things go and why. just to see it create the classes, step through the code it generates.
The "packaging" part of it all is kinda confusing the first few reads though. Obviously that’s only part of a full tutorial, so when i was done, I just farted around with the custom doodle classes a bit, stepped through some code that added a record or two into the db and deleted the records. Then I and deleted the whole project. (it was good for my learning/remembering process)
anyhoots, I think if you walk though that tut, alot of the docs I’ve ref’ed will start to fall into place for ya. Sorry the the annoying long post, it was good for me to write it all down and remember some of the stuff myself, so I just kept going on it.
Dave