<?php
 
 
class Settings extends DBInteraction
 
{
 
    private $nameCol = "";
 
    private $valueCol = "";
 
    function __construct()
 
    {
 
        $this->nameCol = "Name";
 
        $this->valueCol = "Value";
 
        $this->initialise("Settings",1)
 
            or die("FATAL ERROR: Settings Class Failed to initialize");
 
    }
 
    function Set($name,$value)
 
    {
 
        $record = $this->getRecord($name,$this->nameCol);
 
        if ($record == false)
 
        {
 
            $values = array($this->nameCol=>$name,$this->valueCol=>$value);
 
            return $this->addRecord($values);
 
        }
 
        else
 
        {
 
            $id = $record['ID'];
 
            $values = array($value=>$record[$this->valueCol]);
 
            return $this->modifyRecord($id,$values);
 
        }
 
    }
 
    function Get($name)
 
    {
 
        $record = $this->getRecord($name,$this->nameCol);
 
        return $record[$this->valueCol];
 
    }
 
    function Delete($name)
 
    {
 
        $record = $this->getRecord($name,$this->nameCol);
 
        return $this->deleteRecord($record['ID']);
 
    }
 
}
 
 
?>
 
 |