| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- <?php
- class Option {
- private $id = NULL;
- private $key = NULL;
- private $value = NULL;
- public function __construct($id, $key, $value) {
- $this->id = $id;
- $this->key = $key;
- $this->value = $value;
- }
- /**
- * Get the value of Id
- *
- *
- * @return int
- *
- */
- public function getID() {
- return $this->id;
- }
- /**
- * Set the value of Id
- *
- *
- * @param int id
- *
- */
- public function setID($id) {
- $this->id = $id;
- }
- /**
- * Get the value of Key
- *
- *
- * @return string
- *
- */
- public function getKey() {
- return $this->key;
- }
- /**
- * Set the value of Key
- *
- *
- * @param string key
- *
- */
- public function setKey($key) {
- $this->key = $key;
- }
- /**
- * Get the value of Value
- *
- *
- * @return string
- *
- */
- public function getValue() {
- return $this->value;
- }
- /**
- * Set the value of Value
- *
- *
- * @param string value
- *
- */
- public function setValue($value) {
- $this->value = $value;
- }
- /*
- *
- * Save current option
- *
- */
- public function save() {
- global $db;
- $db->insertQuery("INSERT INTO `options` (`id`, `key`, `value`) VALUES (" . $this->id . ", '" . $this->key . "', '" . $this->value . "') ON DUPLICATE KEY UPDATE `id` = " . $this->id . ", `key` = '" . $this->key . "', `value` = '" . $this->value . "';");
- }
- /**
- * Get Option by Key
- *
- * @param string $key Key
- *
- * @return Option Selected Option
- *
- */
- public static function getOptionByKey($key) {
- global $db;
- $option = $db->selectQuery("SELECT * FROM `options` WHERE `key` = '" . $key . "';");
- if(!$option) {
- return false;
- }
- return new Option($option[0]->id, $option[0]->key, $option[0]->value);
- }
- }
- ?>
|