| 137 | | // Set the child id name |
| 138 | | $child_id = $key.'_id'; |
| 139 | | |
| 140 | | $this->object->$key = new $model(isset($this->object->$child_id) |
| 141 | | // Get the foreign object using the key defined in this object |
| 142 | | ? $this->object->$child_id |
| 143 | | // Get the foreign object using the primary key of this object |
| 144 | | : array($this->class.'_id', $this->object->id)); |
| | 137 | if (empty($this->object->id)) |
| | 138 | { |
| | 139 | // Load an empty model |
| | 140 | $this->object->$key = new $model; |
| | 141 | } |
| | 142 | else |
| | 143 | { |
| | 144 | // Set the child id name |
| | 145 | $child_id = $key.'_id'; |
| | 146 | |
| | 147 | $this->object->$key = new $model(isset($this->object->$child_id) |
| | 148 | // Get the foreign object using the key defined in this object |
| | 149 | ? $this->object->$child_id |
| | 150 | // Get the foreign object using the primary key of this object |
| | 151 | : array($this->class.'_id', $this->object->id)); |
| | 152 | } |