<?xml version="1.0" encoding="UTF-8"?> <model package="TinyStory" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1"> <object class="Story" table="_story" extends="xPDOSimpleObject"> <field key="author" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" /> <field key="name" dbtype="varchar" precision="126" phptype="string" null="false" /> <field key="story" dbtype="text" phptype="string" null="false" /> <field key="lang" dbtype="varchar" precision="3" phptype="string" null="false" /> <field key="fav" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="true" /> <field key="date" dbtype="date" phptype="date" null="false" /> <field key="next" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="true" /> <field key="prev" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="true" /> </object> </model>
<?php class Story extends xPDOSimpleObject {}
<?php $package_path = $modx->getOption('core_path').'components/TinyStory/model/'; $modx->addPackage('TinyStory', $package_path,'modx_'); $query = $modx->newQuery('Story'); $row = $modx->getObject('Story',1); if($row==NULL) { $output="row is NULL"; } else { $output="We have something! Wow!"; } return $output;
This question has been answered by multiple community members. See the first response.
package="tinystory"
$package_path = $modx->getOption('core_path').'components/tinystory/model/';
if your table is 'modx_story'
it should be table="story"
you don't need 'modx_' in your addPackage, since this is the default table-prefix.
and if you define null="false", you should also define a default-value