<?
class ATTRIBUTE {
/** element id number */
var $element;
/** name */
var $name;
/** value */
var $value;
/** id number */
var $id;
function add() {
/** globalize db connection */
global $db;
$this->name = strtolower($this->name);
$this->value = strtolower($this->value);
/** add the attribute to the database */
$query = "INSERT INTO ATTRIBUTES SET
NAME = '$this->name',
VALUE = '$this->value',
ELEMENT = $this->element";
$result = mysql_query($query);
/** get the attributes id number */
$this->id = mysql_insert_id($db);
}
function update() {
if(!$this->id) $this->add();
$query = "UPDATE ATTRIBUTES SET
NAME = '$this->name',
VALUE = '$this->value'
WHERE ID = $this->id";
$result = mysql_query($query);
}
function delete() {
$query = "DELETE FROM ATTRIBUTES WHERE
ID = $this->id";
$result = mysql_query($query);
}
}
?>