<?php
require_once('inc/db_connect.php');
require_once('inc/base.php');
require_once('inc/debug.php');
abstract class KeksData
{
protected $default_table;
protected $raw_data = array();
protected $data = array();
protected $changes = array();
function __get($key)
{
if (array_key_exists($key, $this->data))
return $this->data[$key];
elseif (isset($this->$key))
return $this->$key;
// else werfe fehler
}
function __set($key, $value)
{
if (array_key_exists($key, $this->raw_data))
{
$this->raw_data[$key] = $value;
$this->changes[$key] = $value;
$this->parse($this->raw_data);
}
elseif (array_key_exists($key, $this->data))
$this->data[$key] = $value;
// return false;
elseif (isset($this->$key))
$this->$key = $value;
else
$this->data[$key] = $value;
}
protected function setup()
{
$fields = array();
$res = db_query("DESCRIBE {$this->default_table}");
while ($f = mysql_fetch_object($res))
{
$fields[$f->Field] = $f->Default;
}
$this->raw_data = $fields;
$this->raw_data['id'] = NULL;