Changeset 21 for trunk/UDatabase.pas


Ignore:
Timestamp:
Mar 23, 2018, 3:06:47 PM (7 years ago)
Author:
chronos
Message:
  • Modified: Allow to create and remove tables for XML backend.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UDatabase.pas

    r20 r21  
    143143    Name: string;
    144144    Params: TDbConnectParams;
     145    destructor Destroy; override;
     146    function GetClient: TDbClient;
    145147    property ClientType: TDbClientType read FClientType write SetClientType;
    146148  end;
     
    152154    procedure LoadFromRegistry(Context: TRegistryContext);
    153155    procedure SaveToRegistry(Context: TRegistryContext);
    154     function FindByName(Name: string): TDbConnectProfile;
     156    function SearchByName(Name: string): TDbConnectProfile;
    155157  end;
    156158
     
    170172    function RegisterType(Id: Integer; Name, Title: string;
    171173      FieldType: TFieldType; FieldTypeClass: TFieldTypeSpecificClass): TDataType;
    172     function FindByType(FieldType: TFieldType): TDataType;
    173     function FindByName(Name: string): TDataType;
     174    function SearchByType(FieldType: TFieldType): TDataType;
     175    function SearchByName(Name: string): TDataType;
    174176  end;
    175177
     
    183185    procedure SetConnectProfile(AValue: TDbConnectProfile); virtual;
    184186  public
    185     procedure Query(DbRows: TDbRows; Text: string); virtual;
     187    procedure Query(Text: string; DbRows: TDbRows = nil); virtual;
    186188    procedure LoadTables(Tables: TTables); virtual;
    187189    constructor Create; virtual;
     
    373375end;
    374376
    375 function TDbConnectProfiles.FindByName(Name: string): TDbConnectProfile;
     377function TDbConnectProfiles.SearchByName(Name: string): TDbConnectProfile;
    376378var
    377379  I: Integer;
     
    389391  if FClientType = AValue then Exit;
    390392  if Assigned(FClientType) then begin
    391     Params.Free;
     393    FreeAndNil(Params);
    392394  end;
    393395  FClientType := AValue;
     
    395397    Params := FClientType.ConnectParmasClass.Create;
    396398  end;
     399end;
     400
     401destructor TDbConnectProfile.Destroy;
     402begin
     403  ClientType := nil;
     404  if Assigned(Params) then Params.Free;
     405  inherited Destroy;
     406end;
     407
     408function TDbConnectProfile.GetClient: TDbClient;
     409begin
     410  Result := ClientType.DatabaseClientClass.Create;
     411  Result.ConnectProfile := Self;
    397412end;
    398413
     
    422437end;
    423438
    424 procedure TDbClient.Query(DbRows: TDbRows; Text: string);
     439procedure TDbClient.Query(Text: string; DbRows: TDbRows = nil);
    425440begin
    426441end;
     
    482497end;
    483498
    484 function TDataTypes.FindByType(FieldType: TFieldType): TDataType;
     499function TDataTypes.SearchByType(FieldType: TFieldType): TDataType;
    485500var
    486501  I: Integer;
     
    492507end;
    493508
    494 function TDataTypes.FindByName(Name: string): TDataType;
     509function TDataTypes.SearchByName(Name: string): TDataType;
    495510var
    496511  I: Integer;
     
    510525  DataTypes.Clear;
    511526  for I := Low(TFieldType) to High(TFieldType) do
    512     if I in Types then DataTypes.Add(ADataTypes.FindByType(I));
     527    if I in Types then DataTypes.Add(ADataTypes.SearchByType(I));
    513528end;
    514529
     
    698713  Records.Clear;
    699714  DbRows := TDbRows.Create;
    700   DbClient.Query(DbRows, 'SELECT * FROM ' + Name);
     715  DbClient.Query('SELECT * FROM ' + Name, DbRows);
    701716  for I := 0 to DbRows.Count - 1 do begin
    702717    NewRecord := TRecord.Create;
     
    723738  Records.Clear;
    724739  DbRows := TDbRows.Create;
    725   DbClient.Query(DbRows, 'SELECT COUNT(*) FROM ' + Name);
     740  DbClient.Query('SELECT COUNT(*) FROM ' + Name, DbRows);
    726741  if DbRows.Count = 1 then begin
    727742    RecordsCount := StrToInt(TDictionaryStringString(DbRows[0]).Items[0].Value);
Note: See TracChangeset for help on using the changeset viewer.