PHP Classes

File: Settings.Class.php

Recommend this page to a friend!
  Packages of Sam Stevens   MySQL Abstractor   Settings.Class.php   Download  
File: Settings.Class.php
Role: Example script
Content type: text/plain
Description: Example of DBInteraction Use
Class: MySQL Abstractor
MySQL database abstraction layer
Author: By
Last change:
Date: 19 years ago
Size: 923 bytes
 

 

Contents

Class file image Download
<?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']);
    }
}

?>