Topic: Beginners Questions  (Read 1249 times)

Pages: [1]   Go Down

#1: 22-Aug-2009, 01:24 PM


charliez
Posts: 554

WWW
I want to start using xPDO and I have some newbie questions...

1) is there a way to generate the xml schema automatically from the SQL file?
or do we have to do this manually?

2) what are the class and map templates used for? for different db engines?

3) what is a map file?

4) can somebody explain what is forward-engineer and reverse-engineer a schema?
Is forward-engineer going from xml to classes and maps?

Sorry for the questions, just starting and the docs are sparce...
thanks in advance
Website: www.mercologia.com 
Blog (in Espaņol): Digital Stickiness www.mercologia.com/blog

#2: 22-Aug-2009, 02:07 PM

Moderator

OpenGeek
MODx Co-Founder
Posts: 6,965

damn accurate caricatures...

WWW
1) is there a way to generate the xml schema automatically from the SQL file?
or do we have to do this manually?
You can generate it from a connection to the database containing the tables, though the generator does not yet support InnoDB FK constraints for the relationships; you'll have to add the class relationships in the schema manually afterward.  See the xPDOGenerator class, as well as the build.modx.php in core/model/schema/ which contains a commented call to $generator->writeSchema().  This was used to generate the original MODx model schema to which we added the relationship definitions (i.e. aggregates and composites).

2) what are the class and map templates used for? for different db engines?
The original domain and table classes are generated from the schemas using the class templates, and maps files from the map templates (maps are always regenerated, you have to manually remove class files to regenerate them so you don't accidentally overwrite code you've added to the classes).

3) what is a map file?
A map file contains all of the object/relational mapping metadata which is used by the base table object class, xPDOObject to define baseline properties and behavior for each derivative class. Map files are specific to a particular database engine/table-class implementation in xPDO.

4) can somebody explain what is forward-engineer and reverse-engineer a schema?
Is forward-engineer going from xml to classes and maps?
Correct on forward-engineering; reverse-engineering is the process of generating the XML from an existing set of database tables as detailed in my response to #1 above.

Sorry for the questions, just starting and the docs are sparce...
The docs are definitely sparse but will improve as more folks ask questions, so no apology necessary. Wink
Jason Coward
MODx Co-Founder
xPDO Founder
CTO @ Collabpad
work productively.
work intelligently.
work together.
Light is just a vibration of a note too. Everything is. You've got to keep that in mind.
  Frank Zappa

#3: 22-Aug-2009, 02:29 PM


charliez
Posts: 554

WWW
Thanks a lot Jason, exactly what I wanted...
let me go do my homework now and I will
probably report back later with more questions.
Website: www.mercologia.com 
Blog (in Espaņol): Digital Stickiness www.mercologia.com/blog

#4: 1-Jan-2010, 11:21 AM

eerne
Posts: 118

WWW
I managed to build the schema and read/write some data to the database. If I understand it correctly the table are created the first time one does $pxdo->newObject('objectClass') or $modx->newObject('objectClass') is that correct?

Can I change and build the schema again? Will the Tables be updated?

Or will it be updated when I do an other $modx->newObject('objectClass') call?

thanks and happy new year!

#5: 3-Jan-2010, 10:43 PM

oori
Posts: 51

Quote
I managed to build the schema and read/write some data to the database. If I understand it correctly the table are created the first time one does $pxdo->newObject('objectClass') or $modx->newObject('objectClass') is that correct?

Yes.


Quote
Can I change and build the schema again? Will the Tables be updated?
Or will it be updated when I do an other $modx->newObject('objectClass') call?

Yes - you can change the schema and build it. BUT - it will NOT alter the SQL table, it will only affect xpdo (for example, modifing schema relationships).
If you altered the columns structure in your schema, you'd have to drop the table (and let xpdo recreate it next newObject) or alter it manually.

#6: 3-Jan-2010, 10:57 PM

Foundation

splittingred
Posts: 1,515

i am alt-country rock

WWW
I managed to build the schema and read/write some data to the database. If I understand it correctly the table are created the first time one does $pxdo->newObject('objectClass') or $modx->newObject('objectClass') is that correct?
Yes, but you could do this as well, as it's more proper:

Code:
$manager = $xpdo->getManager();
$manager->createObjectContainer('objectClass');

Quote
Can I change and build the schema again? Will the Tables be updated?
You can most definitely change the schema again. However, the tables will not be auto-updated. You will need to do that manually.
shaun mccormick | modx foundation
modx revolution | jira bugtracker | official docs | svn tracker | api docs
Pages: [1]   Go Up
0 Members and 1 Guest are viewing this topic.