-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.php
More file actions
executable file
·35 lines (30 loc) · 1001 Bytes
/
setup.php
File metadata and controls
executable file
·35 lines (30 loc) · 1001 Bytes
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
<?php
require "autoload.php";
require "src/html/header.php";
$dsn = "mysql:host=" . env("mysql_address") . ";dbname=" . env("mysql_database") . ";port=".env("mysql_port").";charset=utf8mb4";
$options = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false,
];
try {
$pdo = new PDO($dsn, env("mysql_username"), env("mysql_password"), $options);
$pdo->exec("use ". env("mysql_database"));
} catch (\PDOException $e) {
die($e->getMessage()." ".(int)$e->getCode());
}
try {
$req = $pdo->prepare("CREATE TABLE `LONGR` (
`id` TEXT NOT NULL,
`text` TEXT NOT NULL,
`country` TEXT NOT NULL)");
$req->execute();
echo "You may safely delete this file.";
} catch (\PDOException $e) {
if ($e->getCode() == 42) {
echo "You may safely delete this file.";
} else {
echo $e->getMessage()." ".(int)$e->getCode();
}
}
require "src/html/footer.php";