I am fetching rows from a CSV file but while inserting, some records were skipped. What is the solution for that?
while(($line = fgetcsv($file, 10000, ",")) !== FALSE){
$total_data++;
$sql="SELECT id FROM customers WHERE id ='".$line[0]."'";
$db->query( $sql);
$check = $db->resultset();
$num = $db->rowCount();
if($num > 0){
$update_data++;
//$db->query("UPDATE customers SET name = :name, phone=:phone where id=:id");
$db->bind(':name', $line[1]);
$db->bind(':phone', $line[2]);
$db->bind(':id', $line[0]);
$db->execute();
}else{
$insert_data++;
$db->query("INSERT INTO customers(id,name,phone) VALUES (:id,:name,:phone)");
$db->bind(':id',$line[0]);
$db->bind(':name', $line[1]);
$db->bind(':phone', $line[2]);
$db->execute();
}
}