-
Notifications
You must be signed in to change notification settings - Fork 2
/
boot.php
52 lines (40 loc) · 1.37 KB
/
boot.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
<?php
/**
* Bootstrap Product Database
*
* This file is part of OpenTHC Product Database ("PDB").
*
* SDB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3
* as published by the Free Software Foundation.
*
* SDB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with SDB. If not, see <https://www.gnu.org/licenses/>.*
*/
define('APP_ROOT', __DIR__);
error_reporting(E_ALL & ~E_NOTICE);
openlog('openthc-pdb', LOG_ODELAY|LOG_PID, LOG_LOCAL0);
require_once(APP_ROOT . '/vendor/autoload.php');
if ( ! \OpenTHC\Config::init(APP_ROOT) ) {
_exit_html_fail('<h1>Invalid Application Configuration [PDB-029]</h1>', 500);
}
/**
* Singular Database Connection
*/
function _dbc()
{
static $dbc;
if (empty($dbc)) {
$cfg = \OpenTHC\Config::get('database/main');
$dsn = sprintf('pgsql:host=%s;dbname=%s;user=%s;password=%s', $cfg['hostname'], $cfg['database'], $cfg['username'], $cfg['password']);
// $dbf = sprintf('%s/var/variety.sqlite', APP_ROOT);
// $dsn = sprintf('sqlite:%s', $dbf);
$dbc = new \Edoceo\Radix\DB\SQL($dsn);
}
return $dbc;
}