Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Data Model Questions

Importing data (solved)


4 Posts   151 Views


20 August 2014 at 11:54pm Community Member, 198 Posts

Hi there,

Ive extended the CsvBulkLoader (code below) but i have two wee problems one the dates are screwy, the spreadsheets im importing from have the dates in dd/mm/yy hh:mm format and even though i have the site set you UK date when the importer gets a date it imports the data as mm/dd/yy hh:mm if the dates are correct. ie 01/02/2014 10:22 (1st Feb 2014) is imported as 02/01/2014 10:22 (2nd Jan 2014) any help or pointers on that please?

The second problem is that i'd like to set a boolean to 1 if a record has been imported but without adding a field to the spreadsheet to set this i'm unsure how to flag that, any ideas on that?

Hope you can help


class TheSearchCsvBulkLoader extends CsvBulkLoader{
   public $columnMap = array(
      //Straight Import fields
         'Date Missing' => 'DateMissing',
         'Date Found' => 'DateFound',
         'Gender' => 'Gender',
         'Age' => 'Age',
         'Time of Day' => 'TOD',
         'IPP Grid' => 'IPPGR',
         'Find Grid' => 'FindGR',
         'Destination Grid' => 'DestGR',
         'Track Offset (m)' => 'TrackOff',
         'Area Type' => 'AreaType',
         'Notes' => 'Notes',
         'Area' => 'Area.Name',
         'Type' => 'Mipser.Name',
         'Location Type' => 'Location.Name',
         'Survivability' => 'Survivability.Name',
         'Missing From' => 'MissingLoc.Name'
   public $duplicateChecks = array(
      //'SearchID' => 'ID' // This stops duplicate entries
   public $relationCallbacks = array(
      'Area.Name' => array(
         'relationname' => 'Area',
         'callback' => 'getAreabyName'
      'Mipser.Name' => array(
         'relationname' => 'Misper',
         'callback' => 'getMisperbyName'
      'Location.Name' => array(
         'relationname' => 'Location',
         'callback' => 'getLocationbyName'
      'Survivability.Name' => array(
         'relationname' => 'Survivability',
         'callback' => 'getSurvivabilitybyName'
      'MissingLoc.Name' => array(
         'relationname' => 'MissingLoc',
         'callback' => 'getMissingLocbyName'


   public static function getAreabyName($obj, $val, $record){
      return Team::get()->filter('Name', $val)->First();
   public static function getMisperbyName($obj, $val, $record){
      return Type::get()->filter('Name', $val)->First();
   public static function getLocationbyName($obj, $val, $record){
      return Location::get()->filter('Name', $val)->First();
   public static function getSurvivabilitybyName($obj, $val, $record){
      return Survivability::get()->filter('Name', $val)->First();
   public static function getMissingLocbyName($obj, $val, $record){
      return MissingLoc::get()->filter('Name', $val)->First();


23 August 2014 at 5:45am Community Member, 198 Posts



26 August 2014 at 8:50pm Community Member, 198 Posts

Is there any function like onbeforewrite etc that i can extend/use with regards to importing data to add a flag or boolean?



28 August 2014 at 4:39am Community Member, 198 Posts

Ok i ended up being a bit hacky and added a function to a date conversion function see below.

public static function getDateMissing(&$obj, $val, $record){
         $obj->DateMissing = self::convertDate($val);
         $obj->Imported = 1;