コード例 #1
0
ファイル: Sync_blogController.php プロジェクト: apanly/dream
 public function actionRun()
 {
     $sync_list = BlogSyncQueue::find()->where(['status' => -1])->orderBy("id asc")->limit(count(SyncBlogService::$type_mapping))->all();
     if (!$sync_list) {
         return $this->echoLog("no data need to handle");
     }
     $date_now = date("Y-m-d H:i:s");
     foreach ($sync_list as $_item) {
         sleep(1);
         $this->echoLog("--------queue_id:{$_item['id']}---------");
         $tmp_res = SyncBlogService::doSync($_item['type'], $_item['blog_id']);
         $_item->status = $tmp_res ? 1 : 0;
         $_item->updated_time = $date_now;
         $_item->update(0);
         if (!$tmp_res) {
             $this->echoLog(SyncBlogService::getLastErrorMsg());
         }
     }
     return $this->echoLog(" Done ");
 }