Changeset 20 for trunk/DbEngines/UEngineMySQL.pas
- Timestamp:
- Mar 23, 2018, 1:59:25 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DbEngines/UEngineMySQL.pas
r15 r20 12 12 { TDatabaseMySQL } 13 13 14 TDatabaseMySQL = class(TD atabaseClient)14 TDatabaseMySQL = class(TDbClient) 15 15 private 16 16 procedure LoadFields(Table: TTable); 17 procedure LoadTables; 17 protected 18 procedure LoadTables(Tables: TTables); override; 18 19 public 19 20 SqlDatabase: TSqlDatabase; … … 25 26 end; 26 27 28 { TDbConnectParamsMySQL } 29 30 TDbConnectParamsMySQL = class(TDbConnectParams) 31 protected 32 function GetConnectionString: string; override; 33 procedure SetConnectionString(AValue: string); override; 34 public 35 Host: string; 36 Port: Word; 37 end; 38 39 27 40 implementation 41 42 { TDbConnectParamsMySQL } 43 44 function TDbConnectParamsMySQL.GetConnectionString: string; 45 begin 46 Result := 'mysql://' + Host + ':' + IntToStr(Port); 47 end; 48 49 procedure TDbConnectParamsMySQL.SetConnectionString(AValue: string); 50 var 51 URL: TURL; 52 begin 53 URL := TURL.Create; 54 try 55 URL.AsString := AValue; 56 if (URL.Scheme <> 'mysql') and (AValue <> '') then 57 raise Exception.Create('Wrong connection string. Required mysql scheme.'); 58 Host := URL.Host.AsString; 59 Port := URL.Port; 60 finally 61 URL.Free; 62 end; 63 end; 28 64 29 65 { TDatabaseMySQL } … … 51 87 if DbRows2.Count > 0 then begin 52 88 TypeName := TDictionaryStringString(DbRows2[0]).Values['Name']; 53 NewField.DataType := Table.D atabase.Engine.DataTypes.FindByName(TypeName);89 NewField.DataType := Table.DbClient.ClientType.DataTypes.FindByName(TypeName); 54 90 if not Assigned(NewField.DataType) then 55 NewField.DataType := Table.D atabase.Engine.DataTypes.FindByType(ftString);91 NewField.DataType := Table.DbClient.ClientType.DataTypes.FindByType(ftString); 56 92 end else begin 57 93 // Use string as default 58 NewField.DataType := Table.D atabase.Engine.DataTypes.FindByType(ftString);94 NewField.DataType := Table.DbClient.ClientType.DataTypes.FindByType(ftString); 59 95 end; 60 96 Table.Fields.Add(NewField); … … 66 102 end; 67 103 68 procedure TDatabaseMySQL.LoadTables ;104 procedure TDatabaseMySQL.LoadTables(Tables: TTables); 69 105 var 70 106 DbRows: TDbRows; … … 78 114 NewTable := TTable.Create; 79 115 NewTable.Id := StrToInt(TDictionaryStringString(DbRows[I]).Values['Id']); 80 NewTable.D atabase := Database;116 NewTable.DbClient := Self; 81 117 NewTable.Name := TDictionaryStringString(DbRows[I]).Values['Name']; 82 118 NewTable.Caption := TDictionaryStringString(DbRows[I]).Values['Title']; 83 119 LoadFields(NewTable); 84 Database.Tables.Add(NewTable);120 Tables.Add(NewTable); 85 121 end; 86 122 finally … … 112 148 URL := TURL.Create; 113 149 try 114 URL.AsString := Database.ConnectionString;150 URL.AsString := ConnectProfile.Params.ConnectionString; 115 151 if URL.Scheme <> 'mysql' then 116 152 raise Exception.Create('Wrong connection string. Required mysql protocol.'); … … 124 160 SqlDatabase.Database := Copy(URL.Path, 2, High(Integer)); 125 161 SqlDatabase.Connect; 126 LoadTables;127 162 finally 128 163 URL.Free;
Note:
See TracChangeset
for help on using the changeset viewer.