tp5循环插入多条数据

tp5循环插入多条数据


public function insertdata()
{
ini_set(‘max_execution_time’, ‘0’);//设置永不超时,无限执行下去直到结束
$model = new indexModel();
d a t a s = [ ] ; / / 循 环 插 入 一 百 万 f o r ( datas = []; //循环插入一百万 for ( datas=[];//for(i=10000; $i <1000000 ; $i+=10000) {
# code…
$j = $i-10000;
d a t a = d b ( ′ p h o n e r e c o r d ′ ) − > w h e r e ( " i d > = data = db('phone_record')->where("id>= data=db(phonerecord)>where("id>=j and id< i " ) − > s e l e c t ( ) ; f o r e a c h ( i ")->select(); foreach ( i")>select();foreach(data as $key => $value) {
# code…
d a t a s [ datas[ datas[key][‘phone_no’] = $value[‘phone_no’];
d a t a s [ datas[ datas[key][‘mac’] = $value[‘mac’];
d a t a s [ datas[ datas[key][‘area’] = $value[‘area’];
d a t a s [ datas[ datas[key][‘source_station’] = $value[‘source_station’];
d a t a s [ datas[ datas[key][‘up_time’] = $value[‘up_time’];
d a t a s [ datas[ datas[key][‘rad_time’] = $value[‘rad_time’];
}

    	$model->saveAll($datas);
    	unset($datas);//销毁插入的数据数组
	}
	
	/*$re = $model->select();
	if($re){ //模型查询需要转换成数组,查询集合需要用collection()
		$list = collection($re)->toArray();
	}
	print_r($list);*/

}

你可能感兴趣的:(php学习笔记记录demo)