Changeset 22 for trunk/UDatabase.pas


Ignore:
Timestamp:
Mar 24, 2018, 12:33:48 AM (7 years ago)
Author:
chronos
Message:
  • Modified: Tables creation/deletion using SQL syntax for XML backend.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UDatabase.pas

    r21 r22  
    7575  TFields = class(TObjectList)
    7676    Table: TTable;
    77     function FindByName(Name: string): TField;
     77    function SearchByName(Name: string): TField;
    7878    procedure Assign(Source: TFields);
    7979  end;
     
    8484    Parent: TTable;
    8585    Values: TValues;
     86    procedure InitValues;
    8687    procedure Assign(Source: TRecord);
    8788    constructor Create;
     
    9495    Parent: TTable;
    9596    procedure Assign(Source: TRecords);
     97    function SearchByValue(Name, Value: string): TRecord;
    9698  end;
    9799
     
    175177    function SearchByName(Name: string): TDataType;
    176178  end;
     179
     180  TDbRows = USqlDatabase.TDbRows;
    177181
    178182  { TDbClient }
     
    577581end;
    578582
     583function TRecords.SearchByValue(Name, Value: string): TRecord;
     584var
     585  I: Integer;
     586  FieldIndex: Integer;
     587  Field: TField;
     588begin
     589  Result := nil;
     590  Field := Parent.Fields.SearchByName(Name);
     591  if Assigned(Field) then begin
     592    FieldIndex := Parent.Fields.IndexOf(Field);
     593    I := 0;
     594    while (I < Count) and (TValue(TRecord(Items[I]).Values[FieldIndex]).GetString <> Value) do Inc(I);
     595    if I < Count then Result := TRecord(Items[I])
     596      else Result := nil;
     597  end;
     598end;
     599
    579600{ TFields }
    580601
    581 function TFields.FindByName(Name: string): TField;
     602function TFields.SearchByName(Name: string): TField;
    582603var
    583604  I: Integer;
     
    604625
    605626{ TRecord }
     627
     628procedure TRecord.InitValues;
     629var
     630  I: Integer;
     631begin
     632  Values.Clear;
     633  for I := 0 to Parent.Fields.Count - 1 do
     634    Values.Add(TField(Parent.Fields[I]).GetValueClass.Create);
     635end;
    606636
    607637procedure TRecord.Assign(Source: TRecord);
Note: See TracChangeset for help on using the changeset viewer.