Posted by Shadowhand on Thu 1 May 16:08 (modification of post by Webthink-Julian view diff)
report abuse | download | new post
- /**
- * Magic method for getting object and model keys.
- *
- * @param string key name
- * @return mixed
- */
- public function __get($key)
- {
- {
- return $this->object->$key;
- }
- //this condition doesn't need to be here but ensures we don't loop needlessly
- {
- $foreign_table = FALSE;
- foreach ($this->has_one + $this->belongs_to as $table)
- {
- {
- $foreign_table = $table;
- }
- }
- }
- {
- // Set the model name
- // Set the child id name
- $child_id = $key.'_id';
- {
- // Get the foreign object using the key defined in this object
- return $this->object->$key = new $model($this->object->$child_id);
- }
- else
- {
- // Get the foreign object using the primary key of this object
- }
- }
- else
- {
- switch($key)
- {
- case 'table_name':
- return $this->table;
- break;
- case 'class_name':
- return $this->class;
- break;
- case 'auto_save':
- return $this->auto_save;
- break;
- }
- }
- }
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.