This repository has been 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
/
indicia_publisher.php
78 lines (60 loc) · 1.78 KB
/
indicia_publisher.php
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
75
76
77
78
<?php
include("db.php");
include("functions.php");
$file = fopen("comics/indicia_publisher_id.csv","r");
$mysql = fopen("indicia_publisher.sql", "w"); // write into this sql to import
/*
website id ->> mettre dans table website -> remettre foreign key
year -> date
*/
$min = 0;
$max = 10000000;
$i = 0;
var_dump(fgetcsv($file));
/* 0 => string 'id' (length=2)
1 => string 'name' (length=4)
2 => string 'publisher_id' (length=12)
3 => string 'country_id' (length=10)
4 => string 'year_began' (length=10)
5 => string 'year_ended' (length=10)
6 => string 'is_surrogate' (length=12)
7 => string 'notes' (length=5)
8 => string 'url' (length=3)
*/
while(! feof($file)){
$i++;
$val = fgetcsv($file);
if($i > $min){
$id = getInt($val[0]);
$name = parseDoubleQuote($val[1]);
$publisher_id = getInt($val[2]);
$country_id = getInt($val[3]);
$year_began = getDateFromYear($val[4]);
$year_ended = getDateFromYear($val[5]);
$is_surrogate = getInt($val[6]);
$notes = parseDoubleQuote($val[7]);
//$url = parseDoubleQuote($val[8]);
$url = getInt($val[8]);
$query = 'INSERT INTO indicia_publisher(id, name, publisher_id, country_id, year_began, year_ended, is_surrogate, notes, website_id) VALUES(
'.$id.','.$name.',
'.$publisher_id.',
'.$country_id.',
'.$year_began.','.$year_ended.',
'.$is_surrogate.',
'.$notes.','.$url.'
);';
//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);
?>