如何使用PHP往数据库添加大量数据
程序员文章站
2022-03-04 19:54:22
...
<?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/>";
}
}
推荐阅读