summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMalf Furious <m@lfurio.us>2016-02-02 19:52:07 -0500
committerMalf Furious <m@lfurio.us>2016-02-02 19:52:07 -0500
commit7d484a70f73bd679e0dcf18d23d8124d8edf8f63 (patch)
tree26a4abd97f9d2d72d910d1fd20fd82d32a8a4a5b
parentfaa6ca0b2e9430d2f9d689aab583a7f881ed03bf (diff)
downloadscrott-7d484a70f73bd679e0dcf18d23d8124d8edf8f63.tar.gz
scrott-7d484a70f73bd679e0dcf18d23d8124d8edf8f63.zip
Add helper function to Setting class
Added a static helper function to replacing (or inserting) an option value in the database, longhand.
-rw-r--r--app/class/setting.class.php17
1 files changed, 17 insertions, 0 deletions
diff --git a/app/class/setting.class.php b/app/class/setting.class.php
index ea5fac3..b48f241 100644
--- a/app/class/setting.class.php
+++ b/app/class/setting.class.php
@@ -23,6 +23,23 @@ class Setting extends Framework
return $res[0]['value'];
}
+
+ /*
+ * Helper function for setting setting values on the database
+ */
+ static function setValue($key, $value)
+ {
+ $db = parent::getDbConnection();
+ $escdKey = $db->esc($key);
+ $escdValue = $db->esc($value);
+
+ if (self::getValue($key) === false)
+ $query = "INSERT INTO setting (`key`, value) VALUES('" . $escdKey . "', '" . $escdValue . "')";
+ else
+ $query = "UPDATE setting SET value = '" . $escdValue . "' WHERE `key` = '" . $escdKey . "'";
+
+ $db->query($query);
+ }
}
?>