We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 42838
    • 28 Posts
    As example i getting model from lesson "doodles":

    <?xml version="1.0" encoding="UTF-8"?>
    <model package="doodles" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
    <object class="Doodle" table="doodles" extends="xPDOSimpleObject">
    <field key="name" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
    <field key="description" dbtype="text" phptype="string" null="false" default=""/>

    <field key="createdon" dbtype="datetime" phptype="datetime" null="true"/>
    <field key="createdby" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0" />
    <field key="editedon" dbtype="datetime" phptype="datetime" null="true"/>
    <field key="editedby" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0" />

    <aggregate alias="CreatedBy" class="modUser" local="createdby" foreign="id" cardinality="one" owner="foreign"/>
    <aggregate alias="EditedBy" class="modUser" local="editedby" foreign="id" cardinality="one" owner="foreign"/>
    </object>
    </model>
    now second, i copied and combine two files from documentation, after this i have it code
    <?php

    define('MODX_BASE_PATH', 'D:/www/localhost/');
    define('MODX_CORE_PATH', MODX_BASE_PATH . 'core/');
    define('MODX_MANAGER_PATH', MODX_BASE_PATH . 'manager/');
    define('MODX_CONNECTORS_PATH', MODX_BASE_PATH . 'connectors/');
    define('MODX_ASSETS_PATH', MODX_BASE_PATH . 'assets/');

    define('MODX_BASE_URL','/modx/');
    define('MODX_CORE_URL', MODX_BASE_URL . 'core/');
    define('MODX_MANAGER_URL', MODX_BASE_URL . 'manager/');
    define('MODX_CONNECTORS_URL', MODX_BASE_URL . 'connectors/');
    define('MODX_ASSETS_URL', MODX_BASE_URL . 'assets/');

    include_once MODX_CORE_PATH . 'model/modx/modx.class.php';
    $modx= new modX();
    $modx->initialize('mgr');
    //$modx->loadClass('transport.modPackageBuilder','',false, true);
    echo '<pre>'; /* used for nice formatting of log messages */
    $modx->setLogLevel(modX::LOG_LEVEL_INFO);
    $modx->setLogTarget('ECHO');

    $root = dirname(dirname(__FILE__)).'/';
    $sources = array(
    'model' => MODX_BASE_PATH.'core/components/importer/model/',
    'schema_file' => MODX_BASE_PATH.'core/components/importer/model/schema/doodles.mysql.schema.xml',
    );
    $manager= $modx->getManager();
    $generator= $manager->getGenerator();

    if (!is_dir($sources['model'])) { $modx->log(modX::LOG_LEVEL_ERROR,'Model directory not found!'); die(); }
    if (!file_exists($sources['schema_file'])) { $modx->log(modX::LOG_LEVEL_ERROR,'Schema file not found!'); die(); }
    $generator->parseSchema($sources['schema_file'],$sources['model']);

    //$modx->addPackage('importer', MODX_BASE_PATH.'core/components/importer/model/');

    echo 'Готово.';
    exit();
    this code does not send message error and i have files class into directory model/doodles. I make simple snipped:
    $modx->addPackage('doodles', MODX_CORE_PATH.'/components/importer/model/');
    $c = $modx->newQuery('Doodle');
    $c->prepare();
    return $c->toSQL();
    /*
    returned string
    */
    SELECT `Doodle`.`id` AS `Doodle_id`, `Doodle`.`name` AS `Doodle_name`, `Doodle`.`description` AS `Doodle_description`, `Doodle`.`createdon` AS `Doodle_createdon`, `Doodle`.`createdby` AS `Doodle_createdby`, `Doodle`.`editedon` AS `Doodle_editedon`, `Doodle`.`editedby` AS `Doodle_editedby` FROM `modx_doodles` AS `Doodle`
    I see it as a working model, but i would like get table and i make next snipped:
    $modx->addPackage('doodles', MODX_CORE_PATH.'/components/importer/model/');

    $m = $modx->getManager();
    $m = $m->createObjectContainer('doodles');
    return $m?'true':'false';
    ...and i have flase. I am really sorry for my awful English, but Russian community it is really dead space
      • 42838
      • 28 Posts
      please, see it. my be i have error or i have wrong path for create table
        • 42838
        • 28 Posts
        I found error! I have wrong parameter in createObject Container method. I must set is name my table, but i set name of package.