PHP 批量插入数据

foreach ($sheetContent as $k => $v){
    $arr[‘customerName‘] = $v[0];
    $arr[‘sex‘] = $v[1];
    $arr[‘typeId‘] = $v[2];
    $arr[‘customerPhone‘] = $v[3];
    $arr[‘sourceId‘] = $v[4];
    $arr[‘birthday‘] = $v[5];
    $arr[‘customerwechat‘] = $v[6];
    $arr[‘customer_remarks‘] = $v[7];
    $arr[‘createTime‘] = time();
    $res[] = $arr;
};
 
$num = 100;//每次导入条数
$limit = ceil(count($res)/$num);
for($i=1;$i<=$limit;$i++){
    $offset=($i-1)*$num;
    $data=array_slice($res,$offset,$num);
    $result=Db::name(‘customer‘)->insertAll($data);
};

  

PHP 批量插入数据

上一篇:IDEA的maven项目META-INF文件夹放在哪里


下一篇:js实现模拟下拉菜单