mirror of
https://github.com/Floriansylvain/projet_programmation_web.git
synced 2026-08-19 19:53:18 +02:00
🚚 Moving the extract script inside index.php into his own script file.
This commit is contained in:
+1
-21
@@ -1,23 +1,3 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once("conf.php");
|
echo "Welcome";
|
||||||
require_once("class/these.php");
|
|
||||||
require_once("class/dump.php");
|
|
||||||
|
|
||||||
|
|
||||||
if (($handle = fopen("scripts/dump_abes_thesesfr.csv", "r")) !== FALSE) {
|
|
||||||
$row = 1;
|
|
||||||
$new_these = these::emptyThese();
|
|
||||||
while (($data = fgetcsv($handle, 10000, ";")) !== FALSE) {
|
|
||||||
$num = count($data);
|
|
||||||
// echo "<p>---------------- " . $row . " -----------------<br /></p>\n";
|
|
||||||
if ($row > 1) {
|
|
||||||
for ($c = 0 ; $c < $num ; $c++) {
|
|
||||||
$new_these->insertField($data[$c], $c);
|
|
||||||
}
|
|
||||||
$dump = new dump($new_these);
|
|
||||||
$dump->sendThese();
|
|
||||||
} $row++;
|
|
||||||
}
|
|
||||||
fclose($handle);
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once("../conf.php");
|
||||||
|
require_once("../class/these.php");
|
||||||
|
require_once("../class/dump.php");
|
||||||
|
|
||||||
|
|
||||||
|
if (($handle = fopen("dump_abes_thesesfr.csv", "r")) !== FALSE) {
|
||||||
|
$row = 1;
|
||||||
|
$new_these = these::emptyThese();
|
||||||
|
while (($data = fgetcsv($handle, 10000, ";")) !== FALSE) {
|
||||||
|
$num = count($data);
|
||||||
|
if ($row > 1) {
|
||||||
|
for ($c = 0 ; $c < $num ; $c++) {
|
||||||
|
$new_these->insertField($data[$c], $c);
|
||||||
|
}
|
||||||
|
$dump = new dump($new_these);
|
||||||
|
$dump->sendThese();
|
||||||
|
} $row++;
|
||||||
|
}
|
||||||
|
fclose($handle);
|
||||||
|
echo "CSV file imported into DB.";
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user