From 3af018bfd14f4420fcbda50f4d25bc8f57bcb610 Mon Sep 17 00:00:00 2001 From: Airikr Date: Sun, 9 Jun 2024 18:08:35 +0200 Subject: [PATCH] Database change --- functions/sql.php | 30 ++++++++++-------------------- site-config.php | 1 + site-settings.php | 2 +- 3 files changed, 12 insertions(+), 21 deletions(-) diff --git a/functions/sql.php b/functions/sql.php index f248e21..e3b95e7 100755 --- a/functions/sql.php +++ b/functions/sql.php @@ -1,44 +1,34 @@ prepare($query); - if($method == 'count') { + $prepare = $sql->query($query); $prepare->execute($array); $data = $prepare->fetchColumn(); return $data; + } elseif($method == 'insert') { + $prepare = $sql->prepare($query); + $prepare->execute($array); } elseif($method == 'fetch') { + $prepare = $sql->query($query); $prepare->execute($array); - $data = $prepare->fetch(PDO::FETCH_ASSOC); - return $data; - - - } elseif($method == 'insert') { - foreach($array AS $data => $value) { - $prepare->bindValue(':'.$data, $value); - } - - $prepare->execute(); - return $value; - + return $prepare->fetch(); } else { + $prepare = $sql->prepare($query); $prepare->execute($array); - return $prepare; + return $prepare->fetchAll(); } } catch(Exception $e) { throw($e); } - } -?> \ No newline at end of file +?> diff --git a/site-config.php b/site-config.php index 5a0feab..4266908 100755 --- a/site-config.php +++ b/site-config.php @@ -27,6 +27,7 @@ $config_sitelang = 'sv'; $database_host = null; + $database_port = null; $database_name = null; $database_user = null; $database_pass = null; diff --git a/site-settings.php b/site-settings.php index 0b4280c..c8ad00c 100755 --- a/site-settings.php +++ b/site-settings.php @@ -37,7 +37,7 @@ if(!empty($database_host) AND !empty($database_name) AND !empty($database_user) AND !empty($database_pass)) { try { - $sql = new PDO('mysql:host='.$database_host.';dbname='.$database_name, $database_user, $database_pass); + $sql = new PDO('pgsql:host='.$database_host.';port='.$database_port.';dbname='.$database_name.';user='.$database_user.';password='.$database_pass); $sql->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); }