setting manager fixes and improvements

This commit is contained in:
Steffen Schröder 2013-12-09 10:19:29 +01:00
parent c5bedf89dc
commit 690ef2b0bb

View File

@ -199,14 +199,14 @@ class SettingManager {
return false; return false;
} }
$settingStatement->bind_param('ssss', $className, $settingName, $type, $default); $settingStatement->bind_param('ssss', $className, $settingName, $type, $default);
$settingStatement->execute(); $success = $settingStatement->execute();
if ($settingStatement->error) { if ($settingStatement->error) {
trigger_error($settingStatement->error); trigger_error($settingStatement->error);
$settingStatement->close(); $settingStatement->close();
return false; return false;
} }
$settingStatement->close(); $settingStatement->close();
return true; return $success;
} }
/** /**
@ -269,14 +269,14 @@ class SettingManager {
} }
$value = $this->formatSetting($value); $value = $this->formatSetting($value);
$settingStatement->bind_param('sss', $value, $className, $settingName); $settingStatement->bind_param('sss', $value, $className, $settingName);
$settingStatement->execute(); $success = $settingStatement->execute();
if ($settingStatement->error) { if ($settingStatement->error) {
trigger_error($settingStatement->error); trigger_error($settingStatement->error);
$settingStatement->close(); $settingStatement->close();
return false; return false;
} }
$settingStatement->close(); $settingStatement->close();
return true; return $success;
} }
/** /**
@ -286,7 +286,7 @@ class SettingManager {
* @param string $settingname * @param string $settingname
* @return bool * @return bool
*/ */
public function resetSetting($object, $settingname) { public function resetSetting($object, $settingName) {
$className = $this->getClassName($object); $className = $this->getClassName($object);
$mysqli = $this->maniaControl->database->mysqli; $mysqli = $this->maniaControl->database->mysqli;
$settingQuery = "UPDATE `" . self::TABLE_SETTINGS . "` $settingQuery = "UPDATE `" . self::TABLE_SETTINGS . "`
@ -299,13 +299,43 @@ class SettingManager {
return false; return false;
} }
$settingStatement->bind_param('ss', $className, $settingName); $settingStatement->bind_param('ss', $className, $settingName);
$settingStatement->execute(); $success = $settingStatement->execute();
if ($settingStatement->error) { if ($settingStatement->error) {
trigger_error($settingStatement->error); trigger_error($settingStatement->error);
$settingStatement->close();
return false; return false;
} }
$settingStatement->close(); $settingStatement->close();
return true; return $success;
}
/**
* Delete a setting from the database
*
* @param object $object
* @param string $settingname
* @return bool
*/
public function deleteSetting($object, $settingName) {
$className = $this->getClassName($object);
$mysqli = $this->maniaControl->database->mysqli;
$settingQuery = "DELETE FROM `" . self::TABLE_SETTINGS . "`
WHERE `class` = ?
AND `setting` = ?;";
$settingStatement = $mysqli->prepare($settingQuery);
if ($mysqli->error) {
trigger_error($mysqli->error);
return false;
}
$settingStatement->bind_param('ss', $className, $settingName);
$success = $settingStatement->execute();
if ($settingStatement->error) {
trigger_error($settingStatement->error);
$settingStatement->close();
return false;
}
$settingStatement->close();
return $success;
} }
/** /**