-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathinit.php
More file actions
45 lines (39 loc) · 1.24 KB
/
Copy pathinit.php
File metadata and controls
45 lines (39 loc) · 1.24 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
<?php
use Pixie\Connection;
use Pixie\QueryBuilder\QueryBuilderHandler;
global $dotenv;
global $db;
spl_autoload_register(function ($class_name) {
$directory = '../classes/';
$class_name = str_replace('\\', DIRECTORY_SEPARATOR, $class_name);
$file = $directory . $class_name . '.php';
if (file_exists($file)) {
require_once $file;
}
else {
throw new ErrorException("Failed to include class $class_name");
}
});
set_error_handler(function ($errno, $errstr, $errfile, $errline) {
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
});
require_once __DIR__ . '/vendor/autoload.php';
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
$dotenv->load();
try {
$config = [
'driver' => 'mysql',
'host' => $_ENV["DB_HOST"],
'database' => $_ENV["DB_NAME"],
'username' => $_ENV["DB_USER"],
'password' => $_ENV["DB_PASS"],
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '', // if you have a prefix for all your tables.
];
$connection = new Connection('mysql', $config);
$db = $connection->getQueryBuilder();
} catch (PDOException $e){
require("../views/really_bad_500.php");
die();
}