mirror of
https://github.com/Floriansylvain/projet_programmation_web.git
synced 2026-08-19 11:43:16 +02:00
⚡️ Improved extract script performances
This commit is contained in:
@@ -66,7 +66,7 @@ class dump {
|
|||||||
return $array;
|
return $array;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function sendThese() {
|
public function sendThese($pdo) {
|
||||||
$data = [
|
$data = [
|
||||||
'author' => $this->these->getAuthor(),
|
'author' => $this->these->getAuthor(),
|
||||||
'id_author' => empty($this->these->getIdAuthor()) ? NULL : $this->these->getIdAuthor(),
|
'id_author' => empty($this->these->getIdAuthor()) ? NULL : $this->these->getIdAuthor(),
|
||||||
@@ -87,8 +87,6 @@ class dump {
|
|||||||
'date_update' => empty($this->these->getDateUpdate()) ? NULL : $this->these->getDateUpdate()
|
'date_update' => empty($this->these->getDateUpdate()) ? NULL : $this->these->getDateUpdate()
|
||||||
];
|
];
|
||||||
$sql = "INSERT INTO theses (author, id_author, these_director, title, these_director_name_lastname, id_director, soutenance_establishment, id_establishment, discipline, status, date_first_registration, date_soutenance, language, id_these, online, date_publication, date_update) VALUES (:author, :id_author, :these_director, :title, :these_director_name_lastname, :id_director, :soutenance_establishment, :id_establishment, :discipline, :status, :date_first_registration, :date_soutenance, :language, :id_these, :online, :date_publication, :date_update)";
|
$sql = "INSERT INTO theses (author, id_author, these_director, title, these_director_name_lastname, id_director, soutenance_establishment, id_establishment, discipline, status, date_first_registration, date_soutenance, language, id_these, online, date_publication, date_update) VALUES (:author, :id_author, :these_director, :title, :these_director_name_lastname, :id_director, :soutenance_establishment, :id_establishment, :discipline, :status, :date_first_registration, :date_soutenance, :language, :id_these, :online, :date_publication, :date_update)";
|
||||||
$pdo_obj = new conf();
|
|
||||||
$pdo = $pdo_obj->getPDO();
|
|
||||||
$stmt = $pdo->prepare($sql);
|
$stmt = $pdo->prepare($sql);
|
||||||
$stmt->execute($data);
|
$stmt->execute($data);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ if (($handle = fopen("2021-09-15-theses.csv", "r")) !== FALSE) {
|
|||||||
$stmt = $pdo->query("TRUNCATE `" . getenv('DBNAME') ."`.`theses`");
|
$stmt = $pdo->query("TRUNCATE `" . getenv('DBNAME') ."`.`theses`");
|
||||||
|
|
||||||
$row = 1;
|
$row = 1;
|
||||||
$new_these = these::emptyThese();
|
|
||||||
while (($data = fgetcsv($handle, 10000, ";")) !== FALSE) {
|
while (($data = fgetcsv($handle, 10000, ";")) !== FALSE) {
|
||||||
|
$new_these = these::emptyThese();
|
||||||
$num = count($data);
|
$num = count($data);
|
||||||
if ($row > 1) {
|
if ($row > 1) {
|
||||||
for ($c = 0 ; $c < $num ; $c++) {
|
for ($c = 0 ; $c < $num ; $c++) {
|
||||||
@@ -23,10 +23,9 @@ if (($handle = fopen("2021-09-15-theses.csv", "r")) !== FALSE) {
|
|||||||
}
|
}
|
||||||
$dump = new dump($new_these);
|
$dump = new dump($new_these);
|
||||||
try {
|
try {
|
||||||
$dump->sendThese();
|
$dump->sendThese($pdo);
|
||||||
} catch (Exception) {
|
} catch (Exception $e) {
|
||||||
echo "<br><br>Failed on (" . $row .") :<br>";
|
echo "<br><br>Failed on " . $row ." ( " . $e->getMessage() . " ) :<br>";
|
||||||
var_dump($new_these);
|
|
||||||
}
|
}
|
||||||
} $row++;
|
} $row++;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user