diff --git a/include/class.orm.php b/include/class.orm.php index 0450ef42f7d9f137fc797c39660c10cb06e7e175..8a06eb6ee326e029da4577230101c863ecc3af6f 100644 --- a/include/class.orm.php +++ b/include/class.orm.php @@ -65,6 +65,11 @@ class VerySimpleModel { // Update of foreign-key by assignment to model instance if (isset(static::$meta['joins'][$field])) { $j = static::$meta['joins'][$field]; + if ($j['list'] && ($value instanceof InstrumentedList)) { + // Magic list property + $this->ht[$field] = $value; + return; + } // XXX: Ensure $value instanceof $j['fkey'][0] if ($value->__new__) $value->save(); @@ -99,12 +104,12 @@ class VerySimpleModel { // Construct related lists if (isset(static::$meta['joins'])) { foreach (static::$meta['joins'] as $name => $j) { - if (isset($this->{$j['local']}) + if (isset($this->ht[$j['local']]) && isset($j['list']) && $j['list']) { $fkey = $j['fkey']; - $this->{$name} = new InstrumentedList( + $this->set($name, new InstrumentedList( // Send Model, Foriegn-Field, Local-Id - array($fkey[0], $fkey[1], $this->{$j['local']}) + array($fkey[0], $fkey[1], $this->get($j['local']))) ); } }