Added some caching to Building
This commit is contained in:
@@ -242,17 +242,36 @@ class Building extends mfBaseModel {
|
||||
if($this->$name == null) {
|
||||
|
||||
if($name == "type") {
|
||||
$this->type = new Buildingtype($this->type_id);
|
||||
$type = mfValuecache::singleton()->get("mfObjectmodel-Buildingtype-".$this->type_id);
|
||||
if(!$type) {
|
||||
$type = new Buildingtype($this->type_id);
|
||||
mfValuecache::singleton()->set("mfObjectmodel-Buildingtype-".$this->type_id, $type);
|
||||
}
|
||||
$this->type = $type;
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
if($name == "status") {
|
||||
$this->status = new Buildingstatus($this->status_id);
|
||||
$status = mfValuecache::singleton()->get("mfObjectmodel-Buildingstatus-".$this->status_id);
|
||||
if(!$status) {
|
||||
$status = new Buildingstatus($this->status_id);
|
||||
mfValuecache::singleton()->set("mfObjectmodel-Buildingstatus-".$this->status_id, $status);
|
||||
}
|
||||
$this->status = $status;
|
||||
return $this->status;
|
||||
|
||||
/*$this->status = new Buildingstatus($this->status_id);
|
||||
return $this->status;*/
|
||||
}
|
||||
|
||||
if($name == "pipeworker") {
|
||||
$this->pipeworker = new Address($this->pipeworker_id);
|
||||
$pipeworker = mfValuecache::singleton()->get("mfObjectmodel-Address-".$this->pipeworker_id);
|
||||
if(!$pipeworker) {
|
||||
$pipeworker = new Buildingstatus($this->pipeworker_id);
|
||||
mfValuecache::singleton()->set("mfObjectmodel-Address-".$this->pipeworker_id, $pipeworker);
|
||||
}
|
||||
$this->pipeworker = $pipeworker;
|
||||
//$this->pipeworker = new Address($this->pipeworker_id);
|
||||
return $this->pipeworker;
|
||||
}
|
||||
|
||||
@@ -291,16 +310,20 @@ class Building extends mfBaseModel {
|
||||
$this->pipework_enabler = new User($this->pipework_enabled_by);
|
||||
return $this->pipework_enabler;
|
||||
}
|
||||
|
||||
$classname = ucfirst($name);
|
||||
$idfield = $name."_id";
|
||||
$this->$name = new $classname($this->$idfield);
|
||||
|
||||
if($this->$name->id) {
|
||||
return $this->$name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
$classname = ucfirst($name);
|
||||
$idfield = $name."_id";
|
||||
$this->$name = mfValuecache::singleton()->get("mfObjectmodel-$name-".$this->$idfield);
|
||||
if(!$this->$name) {
|
||||
$this->$name = new $classname($this->$idfield);
|
||||
}
|
||||
|
||||
if($this->$name->id) {
|
||||
mfValuecache::singleton()->set("mfObjectmodel-$name-".$this->$name->id, $this->$name);
|
||||
return $this->$name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->$name;
|
||||
|
||||
Reference in New Issue
Block a user