id = $id;
}
$this->load($id);
}
function load($id) {
if (is_numeric($id)) {
$this->id = $id;
} else {
$this->name = $id;
}
$data = false;
if (is_numeric($this->id)) {
$data = query_row("SELECT * FROM " . DB_PREFIX . $this->getTable() . " WHERE id='{$id}'");
} else if ($this->name) {
$data = query_row("SELECT * FROM " . DB_PREFIX . $this->getTable() . " WHERE name='{$this->name}'");
}
if ($data) {
$this->id = $data->id;
$this->setName($data->name);
return $data;
}
return false;
}
function create() {
$insert = query_insert("INSERT INTO " . DB_PREFIX . $this->getTable() . " (name) values ('".mysql_real_escape_string($this->getName())."')");
return $insert;
}
function build($data) {
global $TeKe;
$this->setName($data["name"]);
/*if ($this->getId() > 0) {
return $this->save();
} else {*/
$id = $this->create();
return $id;
//}
}
function delete() {
global $TeKe;
if (is_numeric($this->getId()) && $this->getId() > 0) {
if ($TeKe->plugin->is_test_constructor() || $this->creator==get_logged_in_user()->getId()) {
return query("DELETE FROM " . DB_PREFIX . $this->getTable() . " WHERE id=".$this->getId());
}
}
return false;
}
public function getId() {
return $this->id;
}
public function setId($id) {
$this->id = $id;
}
public function getTable() {
return $this->table;
}
function setTable($table) {
$this->table = $table;
}
public function getName() {
return $this->name;
}
function setName($name) {
$this->name = $name;
}
function addBuildError($err) {
$this->build_error []= $err;
}
function getBuildError() {
return $this->build_error;
}
}
?>