We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 42655
    • 5 Posts
    I'm working on a custom table insert (code below). When I run the query, I get the following error:

    Could not load metadata map rehasportkurse/mysql/rehasportkurse.map.inc.php for class rehasportkurse from rehasportkurse.mysql.rehasportkurse

    After that error there is another one for each insert.

    Error HY093 executing statement: INSERT INTO `wbrs_rehasportkurse` (`VName`, `Kategorie`, `GName`, `Org_HPBT`, `Org_PLZ`, `Org_Ort`, `Org_Street`, `Org_1UEEH`, `Org_1Tvon`, `Org_1Tbis`, `Org_2UEEH`, `Org_2Tvon`, `Org_2Tbis`, `Org_3UEEH`, `Org_3Tvon`, `Org_3Tbis`, `Ansp`, `AbtTel`, `StB_WsHs`, `StB_GelSch`, `StB_MorBec`, `StB_Endo`, `SB_SehBlind`, `SB_Gehoer`, `GB_GB`, `Krb_Brust`, `Psy_Sucht`, `Psy_Verhalt`, `Psy_PsyErk`, `IO_HK`, `IO_Diab`, `IO_paVers`, `IO_AAll`, `IO_Nier`, `IO_Lunge`, `PZN_cerBewSt`, `PZN_Park`, `PZN_Epi`, `PZN_MS`, `PZN_Apo`, `PZN_QS`, `PZN_Polio`, `GB_Mehrf`, `ADS`, `SBHSBW`, `Funktrain`, `RowID`, `IK-Nr`, `AngebotsID`) VALUES ('TSV Allmendingen', 'Herzsport', 'Herzsport 01', 'Kolleg St. Josef', '89584', 'Ehingen', 'Müllerstr. 8', 'Dienstag', '18:45', '19:45', 'Freitag', '18:30', '19:30', '', '', '', 'Erich Leichtle', '07391 - 53 438', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2595, 440847822, 100200001) Array ( [0] => HY093 [1] => [2] => )


    I've added the package to the system setting 'extension_packages' and I've generated the model/mysql classes for the custom table with Bobs method (http://bobsguides.com/custom-db-tables.html). The files are written and not empty and rehasportkurse.map.inc.php is definately there. How do I properly load all the needed files or how do I avoid this error?

    $modx->addPackage('rehasportkurse',$path.'model/','wbrs_');
    	$fields = array(
    	   'VName'=>$line['VName'],
    	   'Kategorie'=>$line['Kategorie'],
    	   'GName'=>$line['GName'],
    	   'Org_HPBT'=>$line['Org_HPBT'],
    	   'Org_PLZ'=>$line['Org_PLZ'],
    	   'Org_Ort'=>$line['Org_Ort'],
    	   'Org_Street'=>$line['Org_Street'],
    	   'Org_1UEEH'=>$line['Org_1UEEH'],
    	   'Org_1Tvon'=>$line['Org_1Tvon'],
    	   'Org_1Tbis'=>$line['Org_1Tbis'],
    	   'Org_2UEEH'=>$line['Org_2UEEH'],
    	   'Org_2Tvon'=>$line['Org_2Tvon'],
    	   'Org_2Tbis'=>$line['Org_2Tbis'],
    	   'Org_3UEEH'=>$line['Org_3UEEH'],
    	   'Org_3Tvon'=>$line['Org_3Tvon'],
    	   'Org_3Tbis'=>$line['Org_3Tbis'],
    	   'Ansp'=>$line['Ansp'],
    	   'AbtTel'=>$line['AbtTel'],
    	   'StB_WsHs'=>$line['StB_WsHs'],
    	   'StB_AmpGlmas'=>$line['StB_AmpGlmas'],
    	   'StB_Osteo'=>$line['StB_Osteo'],
    	   'StB_GelSch'=>$line['StB_GelSch'],
    	   'StB_MorBec'=>$line['StB_MorBec'],
    	   'StB_Endo'=>$line['StB_Endo'],
    	   'SB_SehBlind'=>$line['SB_SehBlind'],
    	   'SB_Gehoer'=>$line['SB_Gehoer'],
    	   'GB_GB'=>$line['GB_GB'],
    	   'Krb_Brust'=>$line['Krb_Brust'],
    	   'Krb_ProstBlas'=>$line['Krb_ProstBlas'],
    	   'Psy_Sucht'=>$line['Psy_Sucht'],
    	   'Psy_Verhalt'=>$line['Psy_Verhalt'],
    	   'Psy_PsyErk'=>$line['Psy_PsyErk'],
    	   'IO_HK'=>$line['IO_HK'],
    	   'IO_Diab'=>$line['IO_Diab'],
    	   'IO_paVers'=>$line['IO_paVers'],
    	   'IO_AAll'=>$line['IO_AAll'],
    	   'IO_Nier'=>$line['IO_Nier'],
    	   'IO_Lunge'=>$line['IO_Lunge'],
    	   'PZN_cerBewSt'=>$line['PZN_cerBewSt'],
    	   'PZN_Park'=>$line['PZN_Park'],
    	   'PZN_Epi'=>$line['PZN_Epi'],
    	   'PZN_MS'=>$line['PZN_MS'],
    	   'PZN_Apo'=>$line['PZN_Apo'],
    	   'PZN_QS'=>$line['PZN_QS'],
    	   'PZN_Polio'=>$line['PZN_Polio'],
    	   'GB_Mehrf'=>$line['GB_Mehrf'],
    	   'ADS'=>$line['ADS'],
    	   'SBHSBW'=>$line['SBHSBW'],
    	   'Funktrain'=>$line['Funktrain'],
    	   'RowID'=>$line['RowID'],
    	   'IK-Nr'=>$line['IK-Nr'],
    	   'AngebotsID'=>$line['AngebotsID']
    	);
    $rs = $modx->newObject('rehasportkurse');
    $rs-> fromArray($fields, '', false);
    $rs->save();
    


    This question has been answered by boludst. See the first response.

    [ed. note: boludst last edited this post 13 years, 7 months ago.]
    • discuss.answer
      • 42655
      • 5 Posts
      Found out what the problem was:

      One field in the database table was named IK-Nr. Seems like xpdo doesn't like the '-' one bit. Changed it to IK_Nr and it worked like a charm. Is this an XPDO error or is the '-' simply not allowed?
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        If your database name has a hyphen, it must be surrounded with backticks. Hyphens in sql (mysql, anyway) are a reserved character.
        http://dev.mysql.com/doc/refman/5.0/en/identifiers.html
        Permitted characters in unquoted identifiers:

        ASCII: [0-9,a-z,A-Z$_] (basic Latin letters, digits 0-9, dollar, underscore)
          Studying MODX in the desert - http://sottwell.com
          Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
          Join the Slack Community - http://modx.org
          • 42655
          • 5 Posts
          Thanks Susan, should have RTFM...

          By the way, the "map.inc.php not loaded" error went away after I uppercased the 'rehasportkurse' in the object constructor