diff options
author | Malf Furious <m@lfurio.us> | 2017-01-15 05:49:32 -0500 |
---|---|---|
committer | Malf Furious <m@lfurio.us> | 2017-01-15 05:49:32 -0500 |
commit | feb61662d2359414837787111cf0f37e1f57fb5f (patch) | |
tree | 9b160086d2413a390b0634a107ea941953595dc3 /examples/app/class/object.class.php | |
parent | a17463ee221da81d394d4571e3e9b0f2e52d965f (diff) | |
download | scrott-feb61662d2359414837787111cf0f37e1f57fb5f.tar.gz scrott-feb61662d2359414837787111cf0f37e1f57fb5f.zip |
Purge old content
Diffstat (limited to '')
-rw-r--r-- | examples/app/class/object.class.php | 155 |
1 files changed, 0 insertions, 155 deletions
diff --git a/examples/app/class/object.class.php b/examples/app/class/object.class.php index 7c0b7bb..0c02176 100644 --- a/examples/app/class/object.class.php +++ b/examples/app/class/object.class.php @@ -54,161 +54,6 @@ abstract class Object extends Framework } /* - * Populate this object with data from the DB with a given GUID - */ - function loadObj($guid = null) - { - if (is_null($guid)) - return; - - if (!$this->isGUID($guid)) - return; - - $escdGuid = $this->db->esc($guid); - - /* Base fields */ - $query = "SELECT * FROM `" . $this->table . "` WHERE `guid` = '" . $escdGuid . "'"; - $result = $this->db->query($query)[0]; - - foreach ($this->cols as $col) - { - if (isset($result[$col])) - $this->$col = $result[$col]; - } - - /* Child Table fields */ - $query = "SELECT * FROM `" . $this->childTable . "` WHERE `guid` = '" . $escdGuid . "'"; - $result = $this->db->query($query)[0]; - - foreach ($this->childCols as $col) - { - if (isset($result[$col])) - $this->$col = $result[$col]; - } - } - - /* - * Write this object to the database - */ - function saveObj() - { - if (isset($this->guid)) - { - $this->timeUpdated = $this->getCurrentTimestamp(); - - /* Update Base */ - $updateStr = ""; - - foreach ($this->cols as $col) - { - if (!isset($this->$col)) - continue; - - $updateStr .= "`" . $col . "` = '" . $this->db->esc($this->$col) . "', "; - } - - if (strlen($updateStr) > 0) - { - $updateStr = substr($updateStr, 0, -2); // remove ", " from the end - $query = "UPDATE `" . $this->table . "` SET " . $updateStr . " WHERE `guid` = '" . $this->db->esc($this->guid) . "'"; - $this->db->query($query); - } - - /* Update Child */ - $updateStr = ""; - - foreach ($this->childCols as $col) - { - if (!isset($this->$col)) - continue; - - $updateStr .= "`" . $col . "` = '" . $this->db->esc($this->$col) . "', "; - } - - if (strlen($updateStr) > 0) - { - $updateStr = substr($updateStr, 0, -2); // remove ", " from the end - $query = "UPDATE `" . $this->childTable . "` SET " . $updateStr . " WHERE `guid` = '" . $this->db->esc($this->guid) . "'"; - $this->db->query($query); - } - } - - else - { - $this->guid = $this->getNewGUID(); - $this->timeCreated = $this->getCurrentTimestamp(); - $this->timeUpdated = $this->timeCreated; - - /* Insert Base */ - $colsStr = ""; - $valsStr = ""; - - foreach ($this->cols as $col) - { - if (!isset($this->$col)) - continue; - - $colsStr .= "`" . $col . "`, "; - $valsStr .= "'" . $this->db->esc($this->$col) . "', "; - } - - if (strlen($colsStr) > 0) - { - $colsStr = substr($colsStr, 0, -2); // remove ", " - $valsStr = substr($valsStr, 0, -2); - $query = "INSERT INTO `" . $this->table . "` (" . $colsStr . ") VALUES (" . $valsStr . ")"; - $this->db->query($query); - } - - /* Insert Child */ - $colsStr = ""; - $valsStr = ""; - - foreach ($this->childCols as $col) - { - if (!isset($this->$col)) - continue; - - $colsStr .= "`" . $col . "`, "; - $valsStr .= "'" . $this->db->esc($this->$col) . "', "; - } - - if (strlen($colsStr) > 0) - { - $colsStr = substr($colsStr, 0, -2); // remove ", " - $valsStr = substr($valsStr, 0, -2); - $query = "INSERT INTO `" . $this->childTable . "` (" . $colsStr . ") VALUES (" . $valsStr . ")"; - $this->db->query($query); - } - } - } - - /* - * Remove this object from the database - */ - function delObj() - { - if (!isset($this->guid)) - return; - - /* Delete Base */ - $query = "DELETE FROM `" . $this->table . "` WHERE `guid` = '" . $this->db->esc($this->guid) . "'"; - $this->db->query($query); - - /* Delete Child */ - $query = "DELETE FROM `" . $this->childTable . "` WHERE `guid` = '" . $this->db->esc($this->guid) . "'"; - $this->db->query($query); - - /* obj_member garbage collection */ - $query = "DELETE FROM `obj_member` WHERE `guid` = '" . $this->db->esc($this->guid) . "' OR `member` = '" . $this->db->esc($this->guid) . "'"; - $this->db->query($query); - - /* msg_read garbage collection */ - $query = "DELETE FROM `msg_read` WHERE `guid` = '" . $this->db->esc($this->guid) . "' OR `user` = '" . $this->db->esc($this->guid) . "'"; - $this->db->query($query); - } - - /* * Get current timestamp for object database purposes */ function getCurrentTimestamp() |