Esempio n. 1
0
<?php

require_once 'config.php';
$glcBlocksSource = new IpLoc_Base_Csv(GEO_LITE_CITY_BLOCKS_CSV, 2);
$glcBlocksSource->setColumnsNames(array('startIp', 2 => 'locationId'));
$glcLocationsSource = new IpLoc_Base_Csv(GEO_LITE_CITY_LOCATIONS_CSV, 2);
$glcLocationsSource->setColumnsNames(array('id', 'country', 3 => 'city', 5 => 'latitude', 6 => 'longitude'));
$updater = new IpLoc_Base_Updater(IpLocator::getInstance(), INIT_TABLES_MYSQL, $glcBlocksSource, $glcLocationsSource);
$updater->setBulkInsertLimit(DB_BULK_INSERT_LIMIT);
$updater->setDebugCallback('debug');
$updater->update();
Esempio n. 2
0
 protected function importSourceDataToTable($table, IpLoc_Base_Csv $csv)
 {
     $db = $this->detector->getDb();
     $csv->reset();
     $csv->getRows(2);
     // ignore first rows with Copyright and columns names
     $start = microtime(true);
     while ($rows = $csv->getRows($this->bulkInsertLimit)) {
         $db->multiInsert($table, $rows);
         $timeSpent = microtime(true) - $start;
         $percentComplete = $csv->getCurrentPosition() * 100 / $csv->getTotalPositions();
         $timeLeft = $timeSpent * (100 - $percentComplete) / $percentComplete;
         $this->debug('Complete ' . floor($percentComplete) . '% Timeleft ' . floor($timeLeft), true);
     }
 }