Esempio n. 1
0
 public function &__get($key)
 {
     if (array_key_exists($key, $this->data)) {
         $this->access($key);
         return $this->data[$key];
     }
     $column = $this->table->connection->databaseReflection->getReferencedColumn($key, $this->table->name);
     if (array_key_exists($column, $this->data)) {
         $value = $this->data[$column];
         $referenced = $this->table->getReferencedTable($key);
         $ret = isset($referenced[$value]) ? $referenced[$value] : NULL;
         // referenced row may not exist
         return $ret;
     }
     $this->access($key);
     if (array_key_exists($key, $this->data)) {
         return $this->data[$key];
     } else {
         $this->access($key, TRUE);
         $this->access($column);
         if (array_key_exists($column, $this->data)) {
             $value = $this->data[$column];
             $referenced = $this->table->getReferencedTable($key);
             $ret = isset($referenced[$value]) ? $referenced[$value] : NULL;
             // referenced row may not exist
         } else {
             $this->access($column, TRUE);
             trigger_error("Unknown column {$key}", E_USER_WARNING);
             $ret = NULL;
         }
         return $ret;
     }
 }