<![CDATA[ parseSchema - what is wrong here? - My Forums]]> https://forums.modx.com/thread/?thread=30240 <![CDATA[Re: parseSchema - what is wrong here?]]> https://forums.modx.com/thread/30240/parseschema---what-is-wrong-here#dis-post-163912 Quote from: cyclissmo at Oct 15, 2010, 05:07 AM

An imperfection. Bob, I’m shocked. tongue

LOL. You must not be paying attention. wink
]]>
BobRay Oct 15, 2010, 12:26 AM https://forums.modx.com/thread/30240/parseschema---what-is-wrong-here#dis-post-163912
<![CDATA[Re: parseSchema - what is wrong here?]]> https://forums.modx.com/thread/30240/parseschema---what-is-wrong-here#dis-post-163911 ]]> cyclissmo Oct 15, 2010, 12:07 AM https://forums.modx.com/thread/30240/parseschema---what-is-wrong-here#dis-post-163911 <![CDATA[Re: parseSchema - what is wrong here? [SOLVED]]]> https://forums.modx.com/thread/30240/parseschema---what-is-wrong-here#dis-post-163910
There was a problem in the snippet I was using to test the classes I generated. It was so simple and it ran without error so I never looked at it in all the time I was trying to debug this.

Amazingly, this code didn’t throw a PHP error:

$quotations = $modx->getCollection('Quotations' array('topic'=>'Science'));

( foreach($quotations as $quote) {

    $output .= '<br />' . $quote->get('author');

}
return $output;


The extra parend at the beginning of the second line just made it run for a long time and display no output at all. Go figure.]]>
BobRay Oct 14, 2010, 11:12 PM https://forums.modx.com/thread/30240/parseschema---what-is-wrong-here#dis-post-163910
<![CDATA[Re: parseSchema - what is wrong here?]]> https://forums.modx.com/thread/30240/parseschema---what-is-wrong-here#dis-post-163909 Quote from: anso at Oct 14, 2010, 07:53 PM

no "exit();" ?

(really I don’t know why not mention "exit();" can influence the writing of the classes, but that’s the only difference I see with some others build script I’ve read...)
Cheers
It would have been nice, but no effect. Thanks anyway.]]>
BobRay Oct 14, 2010, 04:27 PM https://forums.modx.com/thread/30240/parseschema---what-is-wrong-here#dis-post-163909
<![CDATA[Re: parseSchema - what is wrong here?]]> https://forums.modx.com/thread/30240/parseschema---what-is-wrong-here#dis-post-163908
(really I don’t know why not mention "exit();" can influence the writing of the classes, but that’s the only difference I see with some others build script I’ve read...)
Cheers]]>
anso Oct 14, 2010, 02:53 PM https://forums.modx.com/thread/30240/parseschema---what-is-wrong-here#dis-post-163908
<![CDATA[parseSchema - what is wrong here?]]> https://forums.modx.com/thread/30240/parseschema---what-is-wrong-here#dis-post-163907
This script is running parseSchema() on a simple schema file with objects pasted from the MODx schema.
It’s finding the schema file, writing all the appropriate objects, and reporting success -- but the object classes are basically empty:

<?php
class modSystemSetting extends xPDOObject {}


Here’s the script:

<?php

 if (!defined('MODX_CORE_PATH')) {
    define(MODX_CORE_PATH, 'c:/xampp/htdocs/test/core/');
    include_once MODX_CORE_PATH . '/model/modx/modx.class.php';
    $modx= new modX();
    $modx->initialize('mgr');
}

$pkg = 'test';
$sources = array(
    'package' => MODX_CORE_PATH . 'components/' . $pkg . '/',
    'core' => MODX_CORE_PATH . 'components/'. $pkg . '/core/',
    'model' => MODX_CORE_PATH. 'components/' . $pkg . '/core/model/',
    'schema' => MODX_CORE_PATH . 'components/' . $pkg . '/core/model/schema/',
    );

if (! file_exists($sources['package'])) {
    mkdir($sources['package']);
}

if (! file_exists($sources['core'])) {
    mkdir($sources['core']);
}
if (! file_exists($sources['model'])) {
    mkdir($sources['model']);
}
if (! file_exists($sources['schema'])) {
    mkdir($sources['schema']);
}

$xpdo= new xPDO('mysql:host=localhost;dbname=test','BobRay','biteme','modx_');

$xpdo->setLogLevel(xPDO::LOG_LEVEL_INFO);
$xpdo->setLogTarget(XPDO_CLI_MODE ? 'ECHO' : 'HTML');

$manager= $xpdo->getManager();
$generator= $manager->getGenerator();


$file = $sources['schema'] . $pkg . '.mysql.schema.xml';

if ($generator->parseSchema($file, $sources['model'])) {
     $xpdo->log(xPDO::LOG_LEVEL_INFO, 'Schema file parsed. Files written to '. $sources['model']);
} else {
     $xpdo->log(xPDO::LOG_LEVEL_INFO, 'Error parsing schema file');
}

$xpdo->log(xPDO::LOG_LEVEL_INFO, 'FINISHED');


Here’s the schema file:

<?xml version="1.0" encoding="UTF-8"?>
<model package="test" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM">
    <object class="modSystemSetting" table="system_settings" extends="xPDOObject">
        <field key="key" dbtype="varchar" precision="50" phptype="string" null="false" default="" index="pk" />
        <field key="value" dbtype="text" phptype="string" null="false" default="" />
        <field key="xtype" dbtype="varchar" precision="75" phptype="string" null="false" default="textfield" />
        <field key="namespace" dbtype="varchar" precision="40" phptype="string" null="false" default="core" />
        <field key="area" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
        <field key="editedon" dbtype="timestamp" phptype="timestamp" null="false" attributes="ON UPDATE CURRENT_TIMESTAMP" />

        <aggregate alias="ContextSetting" class="modContextSetting" local="key" foreign="key" cardinality="one" owner="local" />
        <aggregate alias="Namespace" class="modNamespace" local="namespace" foreign="name" cardinality="one" owner="foreign" />
    </object>
    <object class="modAccessContext" table="access_context" extends="modAccess">
        <aggregate alias="Target" class="modContext" local="target" foreign="key" owner="foreign" cardinality="one" />
    </object>
</model>






]]>
BobRay Oct 14, 2010, 12:05 PM https://forums.modx.com/thread/30240/parseschema---what-is-wrong-here#dis-post-163907