We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 34004
    • 125 Posts
    I have a table:

    CREATE TABLE `cr_runnerEntrant` (
      `AutoId` int(10) NOT NULL AUTO_INCREMENT,
      `BibNumber` int(4) DEFAULT NULL,
      `eb_checked_in` int(4) DEFAULT NULL,
      `alphaCountryCode` varchar(2) DEFAULT NULL,
      `timeAdded` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
      PRIMARY KEY (`AutoId`)
    ) ENGINE=MyISAM AUTO_INCREMENT=13354115 DEFAULT CHARSET=utf8;
    


    I fetch some JSON from another server and insert it have some code:

    $filedata['alphaCountryCode'] = $attendee['profile']['addresses']['home']['country'];
    $filedata['eb_checked_in'] = intval($attendee['checked_in']); // converts JSON true or false into 1 or 0
    $filedata['BibNumber'] = intval($attendee['assigned_number']);
    $addEntrant = $modx->newObject('RunnerEntrant');
    $addEntrant->fromArray($filedata);
    $addEntrant->save();
    


    when I print $filedata I get:

    array(18) { 
      ["alphaCountryCode"]=>
      string(2) "GB"
      ["eb_checked_in"]=>
      int(1) // or int(0) depending if true or false
      ["BibNumber"]=>
      int(6)
    }
    


    alphaCountryCode, BibNumber work fine and insert into the db no worries, but eb_checked_in is always NULL. I can't figure it out, bibNumber is an INT, eb_checked_in is all set up the same - php says it's an INT, but it won't insert. Any clues as to how I can debug this? Thanks
      • 34004
      • 125 Posts
      Any ideas anyone?
      • Could you share your xPDO schema?

        On each field you can specify a phptype as well as a dbtype - my guess is that the phptype is set to something weird that's causing it to handle the data incorrectly.
          Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

          Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
          • 34004
          • 125 Posts
          That's it Mark, I haven't updated the xpdo schema. Been working with Meteor for a long time where you can just insert things and coming back to MODx I totally forgot about that. Thanks so much!