/
drips.php
35 lines (30 loc) · 1.08 KB
/
drips.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
<?php
use Drips\App;
use Drips\Config\Config;
use Drips\Database\DB;
use Drips\Database\Connection;
if (class_exists('Drips\App')) {
App::on('create', function (App $app) {
$type = Config::get('database_type', 'mysql');
$host = Config::get('database_host', 'localhost');
$database = Config::get('database_name', 'drips');
$username = Config::get('database_username', 'root');
$password = Config::get('database_password', 'root');
$port = Config::get('database_port', 3306);
$charset = Config::get('database_charset', 'utf-8');
$config = array(
'database_type' => $type
);
if ($type == 'sqlite') {
$config['database_file'] = $host;
} else {
$config['server'] = $host;
$config['database_name'] = $database;
$config['username'] = $username;
$config['password'] = $password;
$config['port'] = $port;
$config['charset'] = $charset;
}
DB::setConnection('default', new Connection($config, true));
});
}