1

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?

Sean Kimball
  • 4,506
  • 9
  • 42
  • 73
  • Not familiar with modx, but: is there a build phase or something that would create the necessary `modx_static_values` table? Or perhaps it has tried and failed, and looking in your logs may indicate why? – halfer Jun 28 '14 at 19:14
  • actually it works the other way around, it's a modx package that creates the classes etc ~from~ my already existing DB table. – Sean Kimball Jun 28 '14 at 19:18
  • Ah right. Well, it looks like it is trying to access this existing table and finding that it does not exist. Database user permissions wrong maybe, or looking in the wrong database? Edit: ah, it's not taking the prefix into account, gotcha. Other than tracing this manually, no idea I'm afraid! – halfer Jun 28 '14 at 19:20
  • Possible similar issue: http://forums.modx.com/index.php/topic,49942.0.html – halfer Jun 28 '14 at 19:23
  • 1
    thanks for trying, but I think I have it - 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. might be a bug in the cmpgenerator package. – Sean Kimball Jun 28 '14 at 19:54
  • Cool. If you suspect a bug, ping it to the modx devs, who should be able to confirm and log it. If this is sorted in the meantime, please add an answer below, and tick - we welcome self-answers here. It may be of use to someone else. – halfer Jun 28 '14 at 20:28
  • Already done, I think its Bob Ray who maintains this particular package. [FYI: as a rule, the modx developers are very active, very helpful and very accessible in the modx forums ~ as well as here :)] – Sean Kimball Jun 28 '14 at 20:37

1 Answers1

1

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'

Sean Kimball
  • 4,506
  • 9
  • 42
  • 73
  • There is a [CMPGenerator](http://modx.com/extras/package/cmpgenerator) component. It helps to generate modx object's map (cause modx using them to operate with objects instead of xml schema) from you db. – rogaldh Jun 29 '14 at 08:58
  • Database field names have to contain at least one letter. http://www.informit.com/articles/article.aspx?p=30875 – W. Shawn Wilkerson Aug 09 '15 at 21:09