asArray()->all(); \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; return [ 'code' => 200, 'data'=>$pages, 'status'=>true ]; } public function actionSynsdata(){ $ga=new GA(); $store="supernova"; $contentpages=$ga->contentpages($store); $i=1; $limit=20; $modelKey=[ 'pagePath', 'store', 'date', 'pageviews', 'uniquePageviews', 'avgTimeOnPage', 'entrances', 'bounceRate', 'exitRate', 'pageValue', 'created_at', ]; if(!empty($contentpages)){ $list=[]; foreach($contentpages as $k=>$v){ $item=[ $v['pagePath'], $store, date('y-m-d',strtotime($v['date'])), $v['pageviews'], $v['uniquePageviews'], $v['avgTimeOnPage'], $v['entrances'], $v['bounceRate'], $v['exitRate'], $v['pageValue'], time(), ]; $list[]=$item; if($i%$limit==0||$i==count($contentpages)){ \Yii::$app->db->createCommand()->batchInsert(ContentPage::tableName(), $modelKey, $list)->execute(); $list=[]; echo 111111;exit; } $i++; } } echo 111111;exit; }