phpmodxmodx-revolutionxpdo

What is causing this modx xpdo error?


I have a custom extra for modx revolution, but it is throwing the error:

[2014-06-28 15:06:21] (ERROR @ /index.php) Error 42S02 executing statement:
Array
(
    [0] => 42S02
    [1] => 1146
    [2] => Table 'db_name.modx_static_values' doesn't exist
)

I'm trying to add the package like this in the constructor:

if (!$this->modx->addPackage('americansurcharge',MODX_CORE_PATH.'components/americansurcharge/model/','gsi_')) {

$this->modx->log(modX::LOG_LEVEL_ERROR,'Problem adding surcharge package. ');

}

The table 'gsi_static_values' does exist and the path is correct [verified] - furthermore in my schema:

<?xml version="1.0" encoding="UTF-8"?>

<model package="AmericanSurcharge" baseClass="xPDOObject" tablePrefix="gsi_" platform="mysql" defaultEngine="MyISAM" version="1.1">

    <object class="StaticValues" table="static_values" extends="xPDOSimpleObject">
    ....some table columns ... 
    </object>


</model>

the table prefix 'gsi_' is explicitly set.

How do I fix this error?


Solution

  • I regenerated the schema with some small changes & got an error: Unknown column 'StaticValues.0' in 'field list' .... wasn't sure why it would be doing that, but I noticed the schema was not quoting table columns that were digits, [I had several columns 301, 304, 401 etc] as soon as I prefixed them [grade_301, grade_304 etc] and regenerated the schema, everything worked just fine.

    Solution = 'Don't use numeric values for table column names'