$name == null) { if(!$this->id) { return null; } if($name == "voiceplan") { $zone = $this->getProperty("voiceplanzone"); if($zone->voiceplan_id) { $voiceplan = new Voiceplan($zone->voiceplan_id); if($voiceplan->id) { $this->voiceplan = $voiceplan; } } return $this->voiceplan; } $classname = ucfirst($name); $idfield = $name."_id"; $this->$name = new $classname($this->$idfield); if($this->$name->id) { return $this->$name; } else { return null; } } return $this->$name; } }