We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4971
    • 964 Posts
    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
      MODX Revo Tutorials:  www.modxperience.com

      MODX Professional Partner
    • Quote from: charliez at Aug 22, 2009, 06:24 PM

      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).

      Quote from: charliez at Aug 22, 2009, 06:24 PM

      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).

      Quote from: charliez at Aug 22, 2009, 06:24 PM

      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.

      Quote from: charliez at Aug 22, 2009, 06:24 PM

      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.

      Quote from: charliez at Aug 22, 2009, 06:24 PM

      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
        • 4971
        • 964 Posts
        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
          MODX Revo Tutorials:  www.modxperience.com

          MODX Professional Partner
          • 8522
          • 145 Posts
          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!
            • 22295
            • 153 Posts
            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.


            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.
              • 28215
              • 4,149 Posts
              Quote from: eerne at Jan 01, 2010, 05:21 PM

              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:

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



              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 | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com