コード例 #1
0
ファイル: MobileDataController.php プロジェクト: Olwn/pm25
 public function actionUpload()
 {
     $result = array('succeed_count' => 0);
     //$token_status = Yii::$app->getResponse()->content['token_status'];
     //if($token_status == 0) return $result;
     $data = Yii::$app->request->post();
     foreach ($data['data'] as $columns) {
         $result['succeed_count'] += DefaultController::saveModel($this->modelClass, $columns);
     }
     return $result;
 }
コード例 #2
0
ファイル: NewMobileDataController.php プロジェクト: Olwn/pm25
 public function actionUpload()
 {
     $result = array('succeed_count' => 0, 'message' => '');
     $token_status = Yii::$app->getResponse()->content['token_status'];
     if ($token_status == -1) {
         $result['message'] = 'no token';
         return $result;
     }
     if ($token_status == 0) {
         $result['message'] = 'invalid token';
         return $result;
     }
     $data = Yii::$app->request->post();
     foreach ($data['data'] as $columns) {
         $result['succeed_count'] += DefaultController::saveModel($this->modelClass, $columns);
     }
     return $result;
 }
コード例 #3
0
ファイル: CreateController.php プロジェクト: Olwn/pm25
 /**
  * This command create new records of city air qualities.
  */
 public function actionData_pm25in()
 {
     $allStationsJsonData = $this->queryAllStationsJSONData();
     $mixed = json_decode($allStationsJsonData, true);
     if (isset($mixed['error'])) {
         echo $mixed['error'];
     } else {
         echo "Dealing with " . count($mixed) . " records.";
         if (count($mixed) != 0) {
             $class = 'app\\models\\AirQuality';
             foreach ($mixed as $value) {
                 DefaultController::saveModel($class, $value);
             }
         }
     }
     /**
             unset($allStationsJsonData);
             unset($mixed);
             
             $allCitiesJsonData = $this->queryOnlyCitiesJSONData();
             $mixed = json_decode($allCitiesJsonData, true);
     
             if (isset($mixed['error']))
             {
                 echo $mixed['error'];
             }
             else
             {
                 echo "Dealing with " . count($mixed) . " records.";
     			if (count($mixed) != 0)
     			{
     				$class = 'app\models\CityAir';
     				foreach ($mixed as $value)
     				{
     					if(DefaultController::saveModel($class, $value) == false)
                             echo "error";
     				}
     			}
             }
             unset($allCitiesJsonData);
             unset($mixed);
     		**/
 }