-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSQL.php
49 lines (39 loc) · 1.08 KB
/
SQL.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
<?php
# SQL
$column_keys = [
"title",
"language_title",
"language",
"type",
"link",
"php_folder",
"website_folder",
"local_website_folder",
"color"
];
$values = [
$website["Data"]["titles"]["en"],
$website["Data"]["titles"]["language"],
$website["full_language"],
$website["Data"]["type"],
$website["Data"]["link"],
$website["Data"]["Folders"]["PHP"]["root"],
$website["Data"]["Folders"]["Website"]["root"],
$website["Data"]["Folders"]["Local website"]["root"],
$website["Data"]["color"]
];
$columns = [];
foreach ($column_keys as $key) {
array_push($columns, $key." VARCHAR(256) NOT NULL");
}
# Create table
$SQL -> create_table($website["Data"]["titles"]["en"], $columns);
# Update SQL database
$website_key = strtolower(str_replace(" ", "_", $website["Data"]["titles"]["en"]));
# Gets columns from SQL Database
$columns_result = $SQL -> select("SELECT * FROM ".$website_key." WHERE language = '".$website["full_language"]."';");
# If columns are empty, insert into table
if (count($columns_result) == 0) {
$SQL -> insert_into_table($website_key, $column_keys, $values);
}
?>