1. <?php
    2. namespace app\index\controller;
    3. use think\Db;
    4. class Index
    5. {
    6. public function index()
    7. {
    8. $begin = time();
    9. for($i=1;$i<=10000;$i++){
    10. $data['id'] = $i;
    11. $data['openid'] = 'fsadfdsgadfsgdfg';
    12. $data['nickname'] = '咔咔';
    13. $data['company'] = '蚂蚁未来';
    14. $data['mobile'] = '15289310354';
    15. $addId = Db::table('wxb_move_user')->order('id desc')->insertGetId($data);
    16. }
    17. $end = time();
    18. echo "用时 ".($end-$begin)." 秒 <hr/>";
    19. }
    20. }

    使用如何使用PHP往数据库添加大量数据 - 图1