summaryrefslogtreecommitdiff
path: root/classes/db.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2021-02-23 08:34:37 +0300
committerAndrew Dolgov <[email protected]>2021-02-23 08:34:37 +0300
commit5229cc58b269bd04b2be7768107697063d95736e (patch)
tree6520dfaf81ec8eb818c4b66f3f348024466c6e00 /classes/db.php
parent4ed91619ddefcaa2bf758361aaccf0844465228b (diff)
parentcae54dad564bc1372f0f6cc11101b6377caef9a9 (diff)
Merge branch 'wip-config-object'
Diffstat (limited to 'classes/db.php')
-rwxr-xr-xclasses/db.php20
1 files changed, 10 insertions, 10 deletions
diff --git a/classes/db.php b/classes/db.php
index 490cecd57..cbfb9e598 100755
--- a/classes/db.php
+++ b/classes/db.php
@@ -17,13 +17,13 @@ class Db
// normal usage is Db::pdo()->prepare(...) etc
public function pdo_connect() {
- $db_port = defined('DB_PORT') && DB_PORT ? ';port=' . DB_PORT : '';
- $db_host = defined('DB_HOST') && DB_HOST ? ';host=' . DB_HOST : '';
+ $db_port = Config::get(Config::DB_PORT) ? ';port=' . Config::get(Config::DB_PORT) : '';
+ $db_host = Config::get(Config::DB_HOST) ? ';host=' . Config::get(Config::DB_HOST) : '';
try {
- $pdo = new PDO(DB_TYPE . ':dbname=' . DB_NAME . $db_host . $db_port,
- DB_USER,
- DB_PASS);
+ $pdo = new PDO(Config::get(Config::DB_TYPE) . ':dbname=' . Config::get(Config::DB_NAME) . $db_host . $db_port,
+ Config::get(Config::DB_USER),
+ Config::get(Config::DB_PASS));
} catch (Exception $e) {
print "<pre>Exception while creating PDO object:" . $e->getMessage() . "</pre>";
exit(101);
@@ -31,18 +31,18 @@ class Db
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- if (DB_TYPE == "pgsql") {
+ if (Config::get(Config::DB_TYPE) == "pgsql") {
$pdo->query("set client_encoding = 'UTF-8'");
$pdo->query("set datestyle = 'ISO, european'");
$pdo->query("set TIME ZONE 0");
$pdo->query("set cpu_tuple_cost = 0.5");
- } else if (DB_TYPE == "mysql") {
+ } else if (Config::get(Config::DB_TYPE) == "mysql") {
$pdo->query("SET time_zone = '+0:0'");
- if (defined('MYSQL_CHARSET') && MYSQL_CHARSET) {
- $pdo->query("SET NAMES " . MYSQL_CHARSET);
+ if (defined('Config::get(Config::MYSQL_CHARSET)') && Config::get(Config::MYSQL_CHARSET)) {
+ $pdo->query("SET NAMES " . Config::get(Config::MYSQL_CHARSET));
}
}
@@ -68,7 +68,7 @@ class Db
}
public static function sql_random_function() {
- if (DB_TYPE == "mysql") {
+ if (Config::get(Config::DB_TYPE) == "mysql") {
return "RAND()";
} else {
return "RANDOM()";