Changeset 14 for trunk/DbEngines/UEngineMySQL.pas
- Timestamp:
- Mar 22, 2018, 7:59:13 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DbEngines/UEngineMySQL.pas
r13 r14 6 6 7 7 uses 8 Classes, SysUtils, UDatabase, USqlDatabase, UHtmlClasses, SpecializedDictionary;8 Classes, Dialogs, SysUtils, UDatabase, USqlDatabase, UHtmlClasses, SpecializedDictionary; 9 9 10 10 type … … 32 32 var 33 33 DbRows: TDbRows; 34 DbRows2: TDbRows; 34 35 NewField: TField; 35 36 I: Integer; 36 37 DataType: Integer; 38 TypeName: string; 37 39 begin 38 40 DbRows := TDbRows.Create; 41 DbRows2 := TDbRows.Create; 39 42 try 40 43 SqlDatabase.Query(DbRows, 'SELECT * FROM `ModelField` WHERE `Model` = ' + IntToStr(Table.Id) + ''); … … 44 47 NewField.Name := TDictionaryStringString(DbRows[I]).Values['Name']; 45 48 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 49 58 NewField.DataType := Table.Database.Engine.DataTypes.FindByType(ftString); 59 end; 50 60 Table.Fields.Add(NewField); 51 61 end; 52 62 finally 53 63 DbRows.Free; 64 DbRows2.Free; 54 65 end; 55 66 end; … … 72 83 NewTable.Caption := TDictionaryStringString(DbRows[I]).Values['Title']; 73 84 LoadFields(NewTable); 74 DbRows2 := TDbRows.Create;75 try76 SqlDatabase.Query(DbRows2, 'SELECT COUNT(*) FROM `' + NewTable.Name + '`');77 if DbRows2.Count = 1 then78 NewTable.RecordsCount := StrToInt(DbRows2[0].Values['COUNT(*)']);79 finally80 DbRows2.Free;81 end;82 85 Database.Tables.Add(NewTable); 83 86 end;
Note:
See TracChangeset
for help on using the changeset viewer.