I am trying to load CSV to an Azure webserver database using PHP. The CSV's are 2000 lines each. I have it working but when I run the file on the web page the database is only updated with 479 entries and I am not sure why. The webpage takes a long time to process then it will show the page saying its completed. Here's what I have for the insert statement.
try {
$connection = new PDO("sqlsrv:server = tcp:".$SrvName.",1433; Database = ".$DBName, $SQL_USER, $SQL_PASS);
if (($handle = fopen("personal.csv", "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
$sql = "INSERT INTO personal (clientId, lastname, ssn)
VALUES ($data[0], $data[1],$data[2])";
$statement = $connection->prepare($sql);
$statement->execute();
}
fclose($handle);
}
} catch(PDOException $error) {
echo $sql . "<br>" . $error->getMessage();
}
Any help is greatly apreciated!