/** * Saves the object to the database * @return integer $siblingId */ function Save($deep = true) { $connection = Database::Connect(); $this->pog_query = "select `siblingid` from `sibling` where `siblingid`='" . $this->siblingId . "' LIMIT 1"; $rows = Database::Query($this->pog_query, $connection); if ($rows > 0) { $this->pog_query = "update `sibling` set \n\t\t\t`attribute`='" . $this->Escape($this->attribute) . "' where `siblingid`='" . $this->siblingId . "'"; } else { $this->pog_query = "insert into `sibling` (`attribute` ) values (\n\t\t\t'" . $this->Escape($this->attribute) . "' )"; } $insertId = Database::InsertOrUpdate($this->pog_query, $connection); if ($this->siblingId == "") { $this->siblingId = $insertId; } if ($deep) { foreach (array_keys($this->_objectList) as $key) { $object =& $this->_objectList[$key]; $object->Save(); $map = new objectsiblingMap(); $map->AddMapping($this, $object); } } return $this->siblingId; }
/** * Saves the object to the database * @return integer $objectId */ function Save($deep = true) { $connection = Database::Connect(); $this->pog_query = "select `objectid` from `object` where `objectid`='" . $this->objectId . "' LIMIT 1"; $rows = Database::Query($this->pog_query, $connection); if ($rows > 0) { $this->pog_query = "update `object` set \n\t\t\t`attribute`='" . $this->Escape($this->attribute) . "', \n\t\t\t`parent_id`='" . $this->parent_Id . "', \n\t\t\t`attribute2`='" . $this->Escape($this->attribute2) . "' where `objectid`='" . $this->objectId . "'"; } else { $this->pog_query = "insert into `object` (`attribute`, `parent_id`, `attribute2` ) values (\n\t\t\t'" . $this->Escape($this->attribute) . "', \n\t\t\t'" . $this->parent_Id . "', \n\t\t\t'" . $this->Escape($this->attribute2) . "' )"; } $insertId = Database::InsertOrUpdate($this->pog_query, $connection); if ($this->objectId == "") { $this->objectId = $insertId; } if ($deep) { foreach ($this->_childList as $child) { $child->objectId = $this->objectId; $child->Save($deep); } foreach ($this->_siblingList as $sibling) { $sibling->Save(); $map = new objectsiblingMap(); $map->AddMapping($this, $sibling); } } return $this->objectId; }