Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.62 KB | None | 0 0
  1. unit AtsSqlAdapter;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, sqldb, mysql56conn, ats_abonents, zcomponent, zconnection;
  9.  
  10. type
  11.  
  12.   { SqlAdapter }
  13.  
  14.   SqlAdapter = class
  15.   private
  16.     _Hostname, _Login, _Password, _DbName: string;
  17.   public
  18.     FConnection: TZConnection;
  19.  
  20.     constructor Create(Hostname, Login, Password, DbName: string);
  21.     destructor Destroy; override;
  22.  
  23.     procedure OpenConnection();
  24.     function SelectQuery(sQuery: string): TSQLQuery;
  25.  
  26.   end;
  27.  
  28. const
  29.   hostname = '127.0.0.1';
  30.   login = 'root';
  31.   password = '#cvjnhbntkm';
  32.   dbname = 'ATS';
  33.  
  34. var
  35.   AtsSQL: SqlAdapter = nil;
  36.  
  37. implementation
  38.  
  39. { SqlAdapter }
  40.  
  41. constructor SqlAdapter.Create(Hostname, Login, Password, DbName: string);
  42. begin
  43.  
  44.   FConnection := TZConnection.Create(nil);
  45.   _Hostname := Hostname;
  46.   _Login := Login;
  47.   _Password := Password;
  48.   _DbName := DbName;
  49.  
  50.   OpenConnection;
  51. end;
  52.  
  53. destructor SqlAdapter.Destroy;
  54. begin
  55.   inherited Destroy;
  56. end;
  57.  
  58. procedure SqlAdapter.OpenConnection;
  59. begin
  60.  
  61.   FConnection.HostName := _Hostname;
  62.   FConnection.User := _Login;
  63.   FConnection.Password := _Password;
  64.   FConnection.Database := _DbName;
  65.  
  66.   //FConnection.Protocol:='mariadb';
  67.  
  68.   //FConnection.Connected := True;
  69.   FConnection.Connect;
  70.  
  71.   //Connection.ConnectorType:='mariadb';
  72.   //Connection.Connected := True;
  73.  
  74.   //Connection.Transaction := Transaction;
  75. end;
  76.  
  77. function SqlAdapter.SelectQuery(sQuery: string): TSQLQuery;
  78. begin
  79.  
  80. end;
  81.  
  82. initialization
  83.   AtsSQL := SqlAdapter.Create(hostname, login, password, dbname);
  84.  
  85. finalization
  86.   if AtsSQL <> nil then
  87.     AtsSQL.Free;
  88.  
  89. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement