$filename = $_FILES['data']['tmp_name'];
$handle = fopen($filename, 'r');
$result = input_csv($handle); //解析csv
$length = count($result);
for ($i = 0; $i < $length; $i++) {
$ip = $result[$i][0];
$port = $result[$i][1];
//...
$data = array(
"ip" => $ip,
"port" => $port,
//...
);
$count = $Property->where($where)->find();
if($count){
$query = $Property->where($where)->save($data);
}else{
$query = $Property->add($data);
}
}
fclose($result);
$this->success('导入成功!');
exit();
上傳CSV文件,執行後就報錯了,求大神支招
ps:必須要判定IP 端口唯一,存在則覆蓋,不存在則添加。