ck1987 发表于 2018-12-14 08:49:09

php 读取csv 并保存数据库

//php 读取csv 并保存数据库  
$file = fopen('test.csv','r');
  
$count = 1;
  

  
//连接数据库
  
$db = new mysqli('localhost','root','root','test',3306);
  
$db->query('SET AUTOCOMMIT=0');
  
$db->query('START TRANSACTION');
  

  
while($data = fgetcsv($file)){
  

  $result = array();
  

  if( $count>1 && !empty($data)){
  

  for($i=0;$iquery($sql);
  

  
}
  

  
$count++;


页: [1]
查看完整版本: php 读取csv 并保存数据库