summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Dibb <beandog@gentoo.org>2010-02-11 20:17:46 -0700
committerSteve Dibb <beandog@gentoo.org>2010-02-11 20:17:46 -0700
commit32a7a5f8d8b36ae6acb6e566ff3d371b7a145c4b (patch)
treef9b8efa8def14998bc8f7a4fed123cc34c98f8db /class.db.category.php
parentZero (diff)
downloadznurt-org-frontend-32a7a5f8d8b36ae6acb6e566ff3d371b7a145c4b.tar.gz
znurt-org-frontend-32a7a5f8d8b36ae6acb6e566ff3d371b7a145c4b.tar.bz2
znurt-org-frontend-32a7a5f8d8b36ae6acb6e566ff3d371b7a145c4b.zip
initial commit
Diffstat (limited to 'class.db.category.php')
-rw-r--r--class.db.category.php51
1 files changed, 51 insertions, 0 deletions
diff --git a/class.db.category.php b/class.db.category.php
new file mode 100644
index 0000000..8ad8456
--- /dev/null
+++ b/class.db.category.php
@@ -0,0 +1,51 @@
+<?
+
+ class DBCategory {
+
+ private $id;
+ private $name;
+ private $arr_keys;
+ private $table;
+ private $arr_db;
+ private $description;
+
+ function __construct($id) {
+
+ if(!is_numeric($id))
+ $id = 0;
+ $this->id = $id;
+
+ $db =& MDB2::singleton();
+ $this->table = 'category';
+
+ // Go ahead and query as much as we can
+ $sql = "SELECT * FROM ".$this->table." WHERE id = ".$db->quote($this->id).";";
+ $this->arr_db = $db->getRow($sql);
+
+ $this->arr_keys = array_keys($this->arr_db);
+ unset($this->arr_keys['id']);
+
+ }
+
+ public function __get($var) {
+ if(in_array($var, $this->arr_keys)) {
+ return $this->arr_db[$var];
+ } else {
+ return $this->$var;
+ }
+ }
+
+ public function __set($var, $value) {
+
+ $db =& MDB2::singleton();
+
+ if(in_array($var, $this->arr_keys)) {
+ $arr_update = array($var => $value);
+ $db->autoExecute($this->table, $arr_update, MDB2_AUTOQUERY_UPDATE, "id = ".$db->quote($this->id));
+ $this->$var = $value;
+ }
+ }
+
+ }
+
+?> \ No newline at end of file