Ignore:
Timestamp:
Dec 29, 2020, 11:11:12 PM (4 years ago)
Author:
chronos
Message:
  • Fixed: Modules dependencies evaluation.
  • Modified: Better installation/uninstallation of models in more modules.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/Common/Base.php

    r889 r890  
    3838{
    3939  public string $Name;
    40   public bool $Nullable;
    4140  public array $Columns;
    4241  public array $Indices;
    4342  public string $PrimaryKey;
    44   public bool $Unique;
    45   public bool $HasDefault;
    46 
    47   function __construct(string $Name, bool $Nullable = false, bool $Unique = false)
     43  public bool $Memory;
     44
     45  function __construct(string $Name)
    4846  {
    4947    $this->Name = $Name;
    5048    $this->Columns = array();
    51     $this->Nullable = $Nullable;
     49    $this->Indices = array();
    5250    $this->PrimaryKey = 'Id';
    53     $this->Unique = $Unique;
     51    $this->Memory = false;
    5452  }
    5553
     
    6159  }
    6260
     61  function AddFloat(string $Name): ModelColumnFloat
     62  {
     63    $Result = new ModelColumnFloat($Name);
     64    $this->Columns[] = $Result;
     65    return $Result;
     66  }
     67
    6368  function AddInteger(string $Name): ModelColumnInteger
    6469  {
     
    7580  }
    7681
     82  function AddDate(string $Name): ModelColumnDate
     83  {
     84    $Result = new ModelColumnDate($Name);
     85    $this->Columns[] = $Result;
     86    return $Result;
     87  }
     88
     89  function AddBoolean(string $Name): ModelColumnBoolean
     90  {
     91    $Result = new ModelColumnBoolean($Name);
     92    $this->Columns[] = $Result;
     93    return $Result;
     94  }
     95
    7796  function AddReference(string $Name, string $RefTable): ModelColumnReference
    7897  {
     
    8099    $this->Columns[] = $Result;
    81100    return $Result;
     101  }
     102
     103  function AddEnum(string $Name, array $States): ModelColumnEnum
     104  {
     105    $Result = new ModelColumnEnum($Name, $States);
     106    $this->Columns[] = $Result;
     107    return $Result;
     108  }
     109
     110  function AddChangeAction(): void
     111  {
     112    $Column = $this->AddEnum('ChangeAction', array('add', 'modify', 'remove'));
     113    $Column->Nullable = true;
     114    $Column = $this->AddDateTime('ChangeTime');
     115    $Column->Nullable = true;
     116    $this->AddInteger('ChangeReplaceId');   
    82117  }
    83118}
     
    91126  const DateTime = 4;
    92127  const Reference = 5;
     128  const Boolean = 6;
     129  const Date = 7;
     130  const Enum = 8;
    93131}
    94132
     
    96134{
    97135  public string $Name;
    98   public ModelColumnType $Type;
    99   public
    100 
    101   function __construct(string $Name, int $Type)
     136  public int $Type; // ModelColumnType
     137  public bool $Nullable;
     138  public bool $Unique;
     139  public bool $HasDefault;
     140
     141  function __construct(string $Name, int $Type, bool $Nullable = false, bool $Unique = false)
    102142  {
    103143    $this->Name = $Name;
    104144    $this->Type = $Type;
     145    $this->Nullable = $Nullable;
     146    $this->Unique = $Unique;
     147    $this->HasDefault = false;
    105148  }
    106149
     
    128171}
    129172
     173class ModelColumnFloat extends ModelColumn
     174{
     175  public ?float $Default;
     176
     177  function __construct(string $Name)
     178  {
     179    parent::__construct($Name, ModelColumnType::Float);
     180    $this->HasDefault = false;
     181    $this->Default = null;
     182  }
     183
     184  function GetDefault(): ?string
     185  {
     186    return '"'.$this->Default.'"';
     187  }
     188}
     189
    130190class ModelColumnText extends ModelColumn
    131191{
     
    169229  {
    170230    parent::__construct($Name, ModelColumnType::DateTime);
     231    $this->HasDefault = false;
     232    $this->Default = null;
     233  }
     234
     235  function GetDefault(): ?string
     236  {
     237    return '"'.$this->Default.'"';
     238  }
     239}
     240
     241class ModelColumnDate extends ModelColumn
     242{
     243  public ?DateTime $Default;
     244
     245  function __construct(string $Name)
     246  {
     247    parent::__construct($Name, ModelColumnType::Date);
    171248    $this->HasDefault = false;
    172249    $this->Default = null;
     
    189266  }
    190267}
     268
     269class ModelColumnBoolean extends ModelColumn
     270{
     271  public ?bool $Default;
     272
     273  function __construct(string $Name)
     274  {
     275    parent::__construct($Name, ModelColumnType::Boolean);
     276    $this->HasDefault = false;
     277    $this->Default = null;
     278  }
     279
     280  function GetDefault(): ?string
     281  {
     282    return $this->Default;
     283  }
     284}
     285
     286class ModelColumnEnum extends ModelColumn
     287{
     288  public ?bool $Default;
     289  public array $States;
     290
     291  function __construct(string $Name, array $States)
     292  {
     293    parent::__construct($Name, ModelColumnType::Enum);
     294    $this->HasDefault = false;
     295    $this->Default = null;
     296    $this->States = $States;
     297  }
     298
     299  function GetDefault(): ?string
     300  {
     301    return $this->Default;
     302  }
     303}
Note: See TracChangeset for help on using the changeset viewer.