Thanking everyone in advance for what will probably be a silly school boy error on my part.
I'm currently converting a website built on Evolution to Revolution and looking to use the database models. I have an external database table (although it is in the MODX database) which contains details about football teams. But every time I to try and use the CMP Generator and then access the database table, I get the following error:
[2012-08-27 19:40:36] (ERROR @ /draytongrange/index.php) Could not get table class for class: teamDetails
[2012-08-27 19:40:36] (ERROR @ /draytongrange/index.php) Could not get table name for class: teamDetails
[2012-08-27 19:40:36] (ERROR @ /draytongrange/index.php) Error 42000 executing statement:
My schema for the table is as below:
<?xml version="1.0" encoding="UTF-8"?>
<model package="teamDetails" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
<object class="TeamDetails" table="teamDetails" extends="xPDOSimpleObject">
<field key="teamAge" dbtype="tinyint" precision="4" phptype="integer" null="false" />
<field key="teamName" dbtype="varchar" precision="25" phptype="string" null="true" />
<field key="managerName" dbtype="varchar" precision="50" phptype="string" null="true" />
<field key="leagueLink" dbtype="varchar" precision="256" phptype="string" null="true" />
<field key="leagueName" dbtype="varchar" precision="56" phptype="string" null="true" />
<field key="displayName" dbtype="varchar" precision="56" phptype="string" null="true" />
<field key="reportTo" dbtype="varchar" precision="128" phptype="string" null="true" />
<field key="leagueEmail" dbtype="varchar" precision="128" phptype="string" null="true" />
</object>
</model>
My class file for this contains:
<?php
class TeamDetails extends xPDOSimpleObject {}
And my code to try and access this database table is :
<?php
// add package so xpdo can be used:
$package_path = $modx->getOption('core_path').'components/teamDetails/model/';
// see the scheme file and the xml model element and you will see the attribute package and that must match here
$modx->addPackage('teamDetails', $package_path);
$c = $modx->newQuery('teamDetails');
$c->select(array('id'));
$c->where(array(
'team' => 1,
));
print "-->".count($modx->getCollection('teamDetails', $c))."<-- Records";
The worst thing is, I've already got this working (by hook or by crook) three times already but this time it doesn't want to play. I would also like to know what I am doing wrong such that I don't have this problem in the future.
I've rebuilt it many times, deleted and started again, used all lower case - but to no avail.
Regards