db = $this->getDbConnection(); $this->table = "object"; $this->cols = array( "guid", "perms", "owner", "parent", "name", "timeCreated", "timeUpdated", "type" ); $this->childTable = $this->db->esc($childTable); $this->childCols = array(); if (is_array($childCols)) { foreach ($childCols as $col) $this->childCols[] = $this->db->esc($col); } } /* * Populate this object with data from the DB with a given GUID */ function loadObj($guid) { if (is_null($guid)) return; $escdGuid = $this->db->esc($guid); /* Common 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]; } } } ?>