Esempio n. 1
0
 /** http://www.streetdirectory.com/sg/1-suites/1-lorong-20-geylang-398721/100869_51869.html
     * @Author: ANH DUNG Mar 04, 2015
     * @Todo: 6-Digit Postal Code Subscription
     * The latest update of the database is attached please.
        The data have been updated as at 10 Feb 2015.
     * @Link: verzview.com/verzpropertyinfo/demo2/site/importApi
     * @cron: s:39:" done in: 285  Second  <=> 4.75 Minutes";
     * s:39:" done in: 273  Second  <=> 4.55 Minutes";
     * s:48:" done in: 235  Second  <=> 3.91666666667 Minutes";
     */
 public function ConsoleImportApiUpdate()
 {
     //        Yii::app()->setting->setDbItem('rss', 0); // for run cron NewsletterCommand
     //        echo Yii::app()->setting->getItem('rss');die;
     //        phpinfo();
     //        echo "need close this line to run. Please read careful step above";die;
     $from = time();
     set_time_limit(72000);
     //        $sql = "insert into {{_api_postcode}} ( postal_code ) values ( '019191K31 MAR0043MAR036999999' ),( '019191K31 MAR0043MAR036' ) ";
     //        Yii::app()->db->createCommand($sql)->execute();die;
     $root = ROOT . '/api';
     // ApiAddress, ApiBuilding, ApiPostcode, ApiStreets, ApiWalkup
     $aInfoImport = array(array('ClassName' => 'ApiWalkup', 'FieldName' => 'walkup', 'file_name' => 'WALKUP.TXT'));
     // array name file to import
     foreach ($aInfoImport as $item) {
         $importFile = $root . "/" . strtolower($item['file_name']);
         if (file_exists($importFile)) {
             $aExists = array();
             $aNew = array();
             $aData = file($importFile, FILE_IGNORE_NEW_LINES);
             ApiPostcode::HandleImport($item['ClassName'], $item['FieldName'], $aData, $aExists, $aNew);
             ApiPostcode::InsertNewRecord($item['ClassName'], $item['FieldName'], $aNew);
         }
     }
     //        ApiPostcode::HandleUpdateLonLatTableBuilding(); // only run from cron job
     $to = time();
     $second = $to - $from;
     echo ' done in: ' . $second . '  Second  <=> ' . $second / 60 . ' Minutes';
     die;
 }