Changeset 345


Ignore:
Timestamp:
Apr 3, 2012, 8:30:29 AM (13 years ago)
Author:
chronos
Message:
  • Modified: MySQL Schema renamed to more general Path. Path will be used for Registry, INI files and other persistent storages.
Location:
PersistentData
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • PersistentData/Backend/UPDClientINI.pas

    r340 r345  
    66
    77uses
    8   Classes, SysUtils, UPDClient;
     8  Classes, SysUtils, UPDClient, IniFiles;
    99
    1010type
     
    1313
    1414  TPDClientINI = class(TPDClient)
     15    IniFile: TIniFile;
    1516    //procedure GetItemList(Condition: TCondition; ItemList: TItemList); override;
    1617    //procedure SetItemList(Condition: TCondition; ItemList: TItemList); override;
     18    FileName: string;
    1719    constructor Create; override;
    1820    destructor Destroy; override;
     21    procedure Connect; override;
     22    procedure Disconnect; override;
    1923  end;
    2024
     
    4246destructor TPDClientINI.Destroy;
    4347begin
     48  Disconnect;
    4449  inherited Destroy;
     50end;
     51
     52procedure TPDClientINI.Connect;
     53begin
     54  IniFile := TIniFile.Create(FileName);
     55end;
     56
     57procedure TPDClientINI.Disconnect;
     58begin
     59  FreeAndNil(IniFile);
    4560end;
    4661
  • PersistentData/Backend/UPDClientMySQL.pas

    r340 r345  
    7575    DbRows := TDbRows.Create;
    7676    Table := '`' + AObject.ObjectName + '`';
    77     if AObject.SchemaName <> '' then Table := '`' + AObject.SchemaName + '`.' + Table;
     77    if AObject.Path <> '' then Table := '`' + AObject.Path + '`.' + Table;
    7878    Database.Query(DbRows, 'SELECT * FROM ' + Table +
    7979      ' WHERE `Id`=' + IntToStr(AObject.Id));
     
    9292  try
    9393    DbRows := TDbRows.Create;
    94     Database.Replace(AObject.ObjectName, AObject.Properties, AObject.SchemaName);
    95     if AObject.Id = 0 then AObject.Id := Database.LastInsertId;
     94    if AObject.Id = 0 then begin
     95      Database.Insert(AObject.ObjectName, AObject.Properties, AObject.Path);
     96      AObject.Id := Database.LastInsertId;
     97    end else Database.Update(AObject.ObjectName, AObject.Properties,
     98      'Id=' + IntToStr(AObject.Id), AObject.Path);
    9699  finally
    97100    DbRows.Free;
     
    102105begin
    103106  Database.Delete(AObject.ObjectName, 'Id=' + IntToStr(AObject.Id),
    104     AObject.SchemaName);
     107    AObject.Path);
    105108end;
    106109
     
    125128      else DbCondition := '';
    126129    Table := '`' + AList.ObjectName + '`';
    127     if AList.SchemaName <> '' then Table := '`' + AList.SchemaName + '`.' + Table;
     130    if AList.Path <> '' then Table := '`' + AList.Path + '`.' + Table;
    128131    Database.Query(DbRows, 'SELECT ' + Filter + ' FROM ' + Table + DbCondition);
    129132    AList.Objects.Clear;
     
    132135      NewObject.Client := AList.Client;
    133136      NewObject.ObjectName := AList.ObjectName;
    134       NewObject.SchemaName := AList.SchemaName;
     137      NewObject.Path := AList.Path;
    135138      NewObject.Properties.Assign(TDictionaryStringString(DbRows[I]));
    136139      AList.Objects.Add(NewObject);
     
    198201    NewProxy := TListProxy.Create;
    199202    NewProxy.Client := Self;
    200     NewProxy.SchemaName := 'information_schema';
     203    NewProxy.Path := 'information_schema';
    201204    NewProxy.ObjectName := 'TABLES';
    202205    NewProxy.Condition := '(TABLE_SCHEMA = "' + Schema +
  • PersistentData/Backend/UPDClientRegistry.pas

    r340 r345  
    66
    77uses
    8   Classes, SysUtils, UPDClient;
     8  Classes, SysUtils, UPDClient, Registry;
    99
    1010type
     
    1313
    1414  TPDClientRegistry = class(TPDClient)
     15    Reg: TRegistry;
    1516    //procedure GetItemList(Condition: TCondition; ItemList: TItemList); override;
    1617    //procedure SetItemList(Condition: TCondition; ItemList: TItemList); override;
     
    3738constructor TPDClientRegistry.Create;
    3839begin
     40  Reg := TRegistry.Create;
    3941  inherited Create;
    4042end;
     
    4244destructor TPDClientRegistry.Destroy;
    4345begin
     46  Reg.Free;
    4447  inherited Destroy;
    4548end;
  • PersistentData/UPDClient.pas

    r340 r345  
    2525    Client: TPDClient;
    2626    ObjectName: string;
    27     SchemaName: string;
     27    Path: string;
    2828    procedure Load;
    2929    procedure Save;
     
    4747    Condition: string;
    4848    ObjectName: string;
    49     SchemaName: string;
     49    Path: string;
    5050    Objects: TListObject; // TListObject<TObjectProxy>
    5151    procedure Clear;
     
    252252  NewProxy := TListProxy.Create;
    253253  NewProxy.Client := Self;
    254   NewProxy.SchemaName := 'information_schema';
     254  NewProxy.Path := 'information_schema';
    255255  NewProxy.ObjectName := 'TABLES';
    256256  NewProxy.Condition := '(TABLE_SCHEMA = "' + Schema +
     
    260260    NewObject := TObjectProxy.Create;
    261261    NewObject.Client := Self;
    262     NewObject.SchemaName := Schema;
     262    NewObject.Path := Schema;
    263263    NewObject.ObjectName := SystemVersionObject;
    264264    NewObject.Id := 1;
     
    278278    NewObject := TObjectProxy.Create;
    279279    NewObject.Client := Self;
    280     NewObject.SchemaName := Schema;
     280    NewObject.Path := Schema;
    281281    NewObject.ObjectName := SystemVersionObject;
    282282    NewObject.Properties.Add('Version', Version);
     
    308308    NewProxy := TListProxy.Create;
    309309    NewProxy.Client := Self;
    310     NewProxy.SchemaName := 'information_schema';
     310    NewProxy.Path := 'information_schema';
    311311    NewProxy.ObjectName := 'TABLES';
    312312    NewProxy.Condition := 'TABLE_SCHEMA = "' + Schema + '"';
Note: See TracChangeset for help on using the changeset viewer.