public function delete() { $database = $this->getDatabase(); $database->transaction(); try { CMSPageNodeLink::deleteFor($this); parent::delete(); } catch (Exception $e) { $database->rollback(); throw $e; } $databsae->commit(); }
if (!isset($when)) { $when = time(); } assert(is_int($when)); if ($when < $this->modified) { throw new InvalidArgumentException("Won't roll back modified time"); } if (isset($this->id)) { $database = $this->getDatabase(); $meta = $this->meta(); $sql = $this->meta()->getSQL('set_modified'); $database->execute($sql, $when, $this->id); } $this->modified = $when; } protected function selfToData() { $data = parent::selfToData(); $data['datatable'] = $this->data->serialize(); return $data; } protected function dataToSelf($data, $save = true) { parent::dataToSelf($data, $save); if (array_key_exists('datatable', $data) && is_array($data['datatable'])) { $this->data->unserialize($data['datatable'], $save); } } } CMSDBObject::$CustomSQL = array_merge(CMSDBObject::$CustomSQL, CMSDBObjectDataTable::$CustomSQL);
protected function dataToSelf($data, $save = true) { parent::dataToSelf($data, $save); if (isset($data['nodes'])) { $nodes = $data['nodes']; foreach ($nodes as $area => $ids) { $nodes[$area] = array_map(array('CMSNode', 'load'), $nodes[$area]); } if ($save) { $this->setNodes($nodes); } else { if (isset($this->linkedNodes)) { $this->linkedNodes = null; } $this->fakeNodes = $nodes; return; } } }