@@ -10,17 +10,20 @@ interface
1010 FireDAC.Comp.Client, FireDAC.Phys.MySQL;
1111
1212type
13+ TConnection = TFDConnection;
14+ TQuery = TFDQuery;
15+
1316 TDAC = class
1417 private
1518 FDriver: TFDPhysMySQLDriverLink;
16- FConnection: TFDConnection ;
17- FQuery: TFDQuery ;
19+ FConnection: TConnection ;
20+ FQuery: TQuery ;
1821 function GetDefaultLibDir : string;
1922 public
2023 constructor Create(aJSON: TJSONObject);
2124 destructor Destroy; override;
22- function getConnection : TFDConnection ;
23- function getQuery : TFDQuery ;
25+ function getConnection : TConnection ;
26+ function getQuery : TQuery ;
2427 end ;
2528
2629implementation
@@ -31,20 +34,20 @@ constructor TDAC.Create(aJSON: TJSONObject);
3134 FDriver.DriverID := ' MySQL' ;
3235 FDriver.VendorLib := GetDefaultLibDir;
3336
34- FConnection := TFDConnection .Create(nil );
37+ FConnection := TConnection .Create(nil );
3538 try
3639 with FConnection do
3740 begin
3841 LoginPrompt := false;
39- Params.Add(' DriverID=FB ' );
42+ Params.Add(' DriverID=MySQL ' );
4043 Params.Add(' Server=' + aJSON.GetValue(' dbserver' ).Value );
4144 Params.Add(' User_Name=' + aJSON.GetValue(' dbuser' ).Value );
4245 Params.Add(' Password=' + aJSON.GetValue(' dbpassword' ).Value );
4346 Params.Add(' Port=' + aJSON.GetValue(' dbport' ).Value );
4447 if aJSON.GetValue(' banco' ) <> nil then
4548 Params.Add(' Database=' + aJSON.GetValue(' banco' ).Value );
4649
47- FQuery := TFDQuery .Create(nil );
50+ FQuery := TQuery .Create(nil );
4851 FQuery.Connection := FConnection;
4952 FQuery.ResourceOptions.SilentMode := true;
5053 end ;
@@ -55,16 +58,13 @@ constructor TDAC.Create(aJSON: TJSONObject);
5558
5659destructor TDAC.Destroy;
5760begin
58- if FDriver <> nil then
59- FDriver.Free;
60- if FQuery <> nil then
61- FQuery.Free;
62- if FConnection <> nil then
63- FConnection.Free;
61+ if Assigned(FDriver) then FreeAndNil(FDriver);
62+ if Assigned(FQuery) then FreeAndNil(FQuery);
63+ if Assigned(FConnection) then FreeAndNil(FConnection);
6464 inherited ;
6565end ;
6666
67- function TDAC.getConnection : TFDConnection ;
67+ function TDAC.getConnection : TConnection ;
6868begin
6969 Result := FConnection;
7070end ;
@@ -95,10 +95,10 @@ function TDAC.GetDefaultLibDir: string;
9595 ' precisam estar na raiz do executável ou na pasta \lib\' );
9696end ;
9797
98- function TDAC.getQuery : TFDQuery ;
98+ function TDAC.getQuery : TQuery ;
9999begin
100100 if not Assigned(FQuery) then
101- FQuery := TFDQuery .Create(nil );
101+ FQuery := TQuery .Create(nil );
102102 Result := FQuery;
103103end ;
104104
0 commit comments