如何使用PHP往數據庫添加大量數據

<?php
namespace app\index\controller;

use think\Db;

class Index
{
    public function index()
    {
        $begin = time(); 		 
    	for($i=1;$i<=10000;$i++){ 
    		 $data['id'] = $i;
    		 $data['openid'] = 'fsadfdsgadfsgdfg';
    		 $data['nickname'] = '咔咔';
    		 $data['company'] = '螞蟻將來';
    		 $data['mobile'] = '15289310354';
    		 $addId = Db::table('wxb_move_user')->order('id desc')->insertGetId($data);
         } 
		$end = time(); 
		echo "用時 ".($end-$begin)." 秒 <hr/>";
	}	    
}

相關文章
相關標籤/搜索