Better settings Manager
This commit is contained in:
parent
74f6779c63
commit
e95435a707
@ -8,10 +8,15 @@ class SettingsManager{
|
|||||||
return Db::loadOne("SELECT * FROM settings WHERE name = ?", array($settingName));
|
return Db::loadOne("SELECT * FROM settings WHERE name = ?", array($settingName));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function create ($name, $value) {
|
static function getSettingGroup($group) {
|
||||||
|
return Db::loadAll("SELECT * FROM settings WHERE group = ?", array($group));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function create ($name, $value, $group = '') {
|
||||||
$setting = array (
|
$setting = array (
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'value' => $value,
|
'value' => $value,
|
||||||
|
'group' => $group,
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
Db::add ('settings', $setting);
|
Db::add ('settings', $setting);
|
||||||
@ -21,12 +26,14 @@ class SettingsManager{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function update ($name, $value) {
|
public static function update ($name, $value, $group = '') {
|
||||||
if ($this.getByName($name)){
|
if ($this.getByName($name)){
|
||||||
$this->create($name, $value);
|
$this->create($name, $value, $group);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
Db::edit ('settings', ['value' => $value], 'WHERE name = ?', array($name));
|
Db::edit ('settings', [
|
||||||
|
'value' => $value
|
||||||
|
], 'WHERE name = ?', array($name));
|
||||||
} catch(PDOException $error) {
|
} catch(PDOException $error) {
|
||||||
echo $error->getMessage();
|
echo $error->getMessage();
|
||||||
die();
|
die();
|
||||||
|
Loading…
Reference in New Issue
Block a user