This repository was archived by the owner on Mar 8, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpublisher.php
More file actions
74 lines (56 loc) · 1.55 KB
/
Copy pathpublisher.php
File metadata and controls
74 lines (56 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
include("db.php");
include("functions.php");
$file = fopen("comics/publisher_id.csv","r");
$mysql = fopen("publisher.sql", "w"); // write into this sql to import
/*
website id ->> mettre dans table website -> remettre foreign key
year -> date
*/
$min = 0;
$max = 1000000;
$i = 0;
var_dump(fgetcsv($file));
/*
0 => string 'id' (length=2)
1 => string 'name' (length=4)
2 => string 'country_id' (length=10)
3 => string 'year_began' (length=10)
4 => string 'year_ended' (length=10)
5 => string 'notes' (length=5)
6 => string 'url' (length=3)
*/
while(! feof($file)){
$i++;
$val = fgetcsv($file);
if($i > $min){
$id = getInt($val[0]);
$name = parseDoubleQuote($val[1]);
$country_id = getInt($val[2]);
$year_began = getDateFromYear($val[3]);
$year_ended = getDateFromYear($val[4]);
$notes = parseDoubleQuote($val[5]);
//$url = parseDoubleQuote($val[6]);
$url = getInt($val[6]);
$query = 'INSERT INTO publisher(id, name, country_id, year_began, year_ended, notes, website_id) VALUES(
'.$id.','.$name.',
'.$country_id.',
'.$year_began.','.$year_ended.',
'.$notes.','.$url.'
);';
//var_dump($query);
//print_r($query);
fwrite($mysql,$query);
$s1 = $con->query($query);
/*var_dump($s1);*/
if($i==$max){
break;
}
}
}
//var_dump($s1->fetchAll(PDO::FETCH_ASSOC));
/*$s = $con->query("SELECT * FROM indicia_publisher ORDER BY id DESC LIMIT 10");
$result = $s->fetchAll(PDO::FETCH_ASSOC);
var_dump($result);*/
fclose($file);
?>