Changeset 378 for trunk/Common/Model.php


Ignore:
Timestamp:
Jan 20, 2012, 3:32:02 PM (13 years ago)
Author:
chronos
Message:
  • Přidáno: Model pro NetworkSegment.
  • Upraveno: Přepracován model systém pro načítání modelů modulů.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Common/Model.php

    r377 r378  
    229229      if($Property['Type'] == PropertyOneToMany)
    230230      {
    231         if(!$this->Module->Models[$Property['TargetModel']]->Installed)
    232           $this->Module->Models[$Property['TargetModel']]->Install();
     231        if(array_key_exists($Property['TargetModel'], $this->Module->Models))
     232        {
     233          if(!$this->Module->Models[$Property['TargetModel']]->Installed)
     234            $this->Module->Models[$Property['TargetModel']]->Install();
     235        }
    233236        $this->Database->query('ALTER TABLE `'.$this->Name.'` ADD FOREIGN KEY (`'.$Property['Name'].'`) REFERENCES `'.$Property['TargetModel'].'` (`Id`);');
    234237      }
     
    238241  function UnInstall()
    239242  {
    240     foreach($Model->Properties as $Property)
     243    foreach($this->Properties as $Property)
    241244    {
    242245      if($Property['Type'] == PropertyManyToMany)
     
    244247    }
    245248    $this->Database->query('DROP TABLE IF EXISTS `'.$this->Name.'`');
     249    $this->Installed = false;
    246250  }
    247251}
Note: See TracChangeset for help on using the changeset viewer.