Ignore:
Timestamp:
Mar 22, 2018, 7:59:13 PM (7 years ago)
Author:
chronos
Message:
  • Added: Support for item references.
  • Added: Data and Time value types.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DbEngines/UEngineMySQL.pas

    r13 r14  
    66
    77uses
    8   Classes, SysUtils, UDatabase, USqlDatabase, UHtmlClasses, SpecializedDictionary;
     8  Classes, Dialogs, SysUtils, UDatabase, USqlDatabase, UHtmlClasses, SpecializedDictionary;
    99
    1010type
     
    3232var
    3333  DbRows: TDbRows;
     34  DbRows2: TDbRows;
    3435  NewField: TField;
    3536  I: Integer;
    3637  DataType: Integer;
     38  TypeName: string;
    3739begin
    3840  DbRows := TDbRows.Create;
     41  DbRows2 := TDbRows.Create;
    3942  try
    4043    SqlDatabase.Query(DbRows, 'SELECT * FROM `ModelField` WHERE `Model` = ' + IntToStr(Table.Id) + '');
     
    4447      NewField.Name := TDictionaryStringString(DbRows[I]).Values['Name'];
    4548      NewField.TextBefore := TDictionaryStringString(DbRows[I]).Values['Title'];
    46       DataType := StrToInt(TDictionaryStringString(DbRows[I]).Values['DataType']);
    47       NewField.DataType := Table.Database.Engine.DataTypes.FindByType(TFieldType(DataType));
    48       if not Assigned(NewField.DataType) then
     49      DataType := StrToInt(TDictionaryStringString(DbRows[I]).Values['Type']);
     50      SqlDatabase.Query(DbRows2, 'SELECT * FROM `DataType` WHERE `Id` = ' + IntToStr(DataType) + '');
     51      if DbRows2.Count > 0 then begin
     52        TypeName := TDictionaryStringString(DbRows2[0]).Values['Name'];
     53        NewField.DataType := Table.Database.Engine.DataTypes.FindByName(TypeName);
     54        if not Assigned(NewField.DataType) then
     55          NewField.DataType := Table.Database.Engine.DataTypes.FindByType(ftString);
     56      end else begin
     57        // Use string as default
    4958        NewField.DataType := Table.Database.Engine.DataTypes.FindByType(ftString);
     59      end;
    5060      Table.Fields.Add(NewField);
    5161    end;
    5262  finally
    5363    DbRows.Free;
     64    DbRows2.Free;
    5465  end;
    5566end;
     
    7283      NewTable.Caption := TDictionaryStringString(DbRows[I]).Values['Title'];
    7384      LoadFields(NewTable);
    74       DbRows2 := TDbRows.Create;
    75       try
    76         SqlDatabase.Query(DbRows2, 'SELECT COUNT(*) FROM `' + NewTable.Name + '`');
    77         if DbRows2.Count = 1 then
    78           NewTable.RecordsCount := StrToInt(DbRows2[0].Values['COUNT(*)']);
    79       finally
    80         DbRows2.Free;
    81       end;
    8285      Database.Tables.Add(NewTable);
    8386    end;
Note: See TracChangeset for help on using the changeset viewer.