load(); if (($handle = fopen("2021-09-15-theses.csv", "r")) !== FALSE) { $pdo_obj = new conf(); $pdo = $pdo_obj->getPDO(); $stmt = $pdo->query("TRUNCATE `" . getenv('DBNAME') ."`.`theses`"); $row = 1; while (($data = fgetcsv($handle, 10000, ";")) !== FALSE) { $new_these = these::emptyThese(); $num = count($data); if ($row > 1) { for ($c = 0 ; $c < $num ; $c++) { $new_these->insertField($data[$c], $c); } $dump = new dump($new_these); try { $dump->sendThese($pdo); } catch (Exception $e) { echo "

Failed on " . $row ." ( " . $e->getMessage() . " ) :
"; } } $row++; } fclose($handle); echo "

CSV file imported into DB. (" . $row . " results)"; }