Added db class

This commit is contained in:
Yiğit Kerem Oktay 2020-08-15 20:21:19 +03:00 committed by GitHub
parent 9af0207549
commit 1c8aea09b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

42
classes/db-class.php Normal file
View File

@ -0,0 +1,42 @@
<?php
class SSDB
{
function execute($link,$sql){
if ($result = mysqli_query($link, $sql)) {
return true;
} else {
die("SQL Failure.Traceback:" . $sql . " Detailed info:" . mysqli_error($link));
}
}
function getSetting($link,$setting){
$sql = "SELECT value FROM settings WHERE setting=\"".$setting."\";";
if($result = mysqli_query($link, $sql)){
if(mysqli_num_rows($result) == 1){
while($row = mysqli_fetch_array($result)){
return $row['value'];
}
}
else{
return "none";
}
}
}
function setSetting($link,$settingname,$settingvalue){
$sql = "INSERT INTO settings (setting,value) VALUES ('".$settingname."','".$settingvalue."');";
if ($result = mysqli_query($link, $sql)) {
return true;
} else {
die("SQL Failure.Traceback:" . $sql . " Detailed info:" . mysqli_error($link));
}
}
function deleteSetting($link,$settingname){
$sql = "DELETE FROM settings WHERE setting=\"".$settingname."\";";
if ($result = mysqli_query($link, $sql)) {
return true;
} else {
die("SQL Failure.Traceback:" . $sql . " Detailed info:" . mysqli_error($link));
}
}
}