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
/
brand_group.php
70 lines (51 loc) · 1.44 KB
/
brand_group.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
<?php
include("db.php");
include("functions.php");
//$file = fopen("comics/brand_group.csv","r");
$file = fopen("comics/brand_group_id.csv","r");
$mysql = fopen("brand_group.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 'year_began' (length=10)
3 => string 'year_ended' (length=10)
4 => string 'notes' (length=5)
5 => string 'url' (length=3)
6 => string 'publisher_id' (length=12)
*/
while(! feof($file)){
$i++;
$val = fgetcsv($file);
if($i > $min){
$id = getInt($val[0]);
$name = parseDoubleQuote($val[1]);
$year_began = getDateFromYear($val[2]);
$year_ended = getDateFromYear($val[3]);
$notes = parseDoubleQuote($val[4]);
//$url = parseDoubleQuote($val[5]);
$url = getInt($val[5]);
$publisher_id = getInt($val[6]);
if(empty($id)) continue;
$query = 'INSERT INTO brand_group(id, name, year_began, year_ended, notes, website_id, publisher_id) VALUES(
'.$id.','.$name.','.$year_began.','.$year_ended.',
'.$notes.','.$url.','.$publisher_id.'
);';
//var_dump($query);
//print_r($query);
fwrite($mysql,$query);
//$s1 = $con->query($query);
/*var_dump($s1);*/
if($i==$max){
break;
}
}
}
fclose($file);
?>