FreeSTAR-Status-Engine/classes/db-class.php
Yiğit Kerem Oktay d2c0808f52
Use object oriented
Use object oriented mysql class for db functions
2020-08-16 21:44:36 +03:00

49 lines
1.2 KiB
PHP

<?php
class SSDB
{
function execute($conn,$sql){
if ($conn->query($sql) === TRUE) {
return true;
} else {
return $conn->error;
}
$conn->close();
}
function getSetting($conn,$setting){
$sql = "SELECT value FROM settings WHERE setting='".$setting."';
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
return $row["value"];
}
} else {
return "null";
}
$conn->close();
}
function setSetting($conn,$settingname,$settingvalue){
$sql = "INSERT INTO settings (setting,value) VALUES ('".$settingname."','".$settingvalue."');";
if ($conn->query($sql) === TRUE) {
return true;
} else {
return $conn->error;
}
$conn->close();
}
function deleteSetting($conn,$settingname){
$sql = "DELETE FROM settings WHERE setting=\"".$settingname."\";";
if ($conn->query($sql) === TRUE) {
return true;
} else {
return $conn->error;
}
$conn->close();
}
}