public function __construct($record = null)
 {
     $this->record = $record;
     $this->query = craft()->db->createCommand()->from('uk_places');
     $this->model = new Ukplaces_PlaceModel();
     if (is_null($this->record)) {
         $this->record = Ukplaces_PlaceRecord::model();
     }
 }
 public function onAfterInstall()
 {
     $path = craft()->path->getPluginsPath() . 'ukplaces/data/towns.csv';
     $csvData = array_map('str_getcsv', file($path));
     unset($csvData[0]);
     $records = array();
     foreach ($csvData as $row) {
         $record = new Ukplaces_PlaceRecord();
         $record->postcode = $row[0];
         $record->eastings = $row[1];
         $record->northings = $row[2];
         $record->latitude = $row[3];
         $record->longitude = $row[4];
         $record->town = $row[5];
         $record->region = $row[6];
         $record->country = $row[8];
         $record->countryCode = $row[7];
         $record->save();
     }
 }