unit mysqldb;
interface
uses Windows, Forms, Messages, SysUtils, Variants, Classes, Graphics, Controls,
DB, ZQuery, ZMySqlQuery, ZTransact, ZMySqlTr, ZConnect, ZMySqlCon;
type TMySQL = class(TThread)
Database: TZMySqlDatabase;
Transact: TZMySqlTransact;
Query: TZMySqlQuery;
public
constructor Create(CreateSuspendend : BOOLEAN);
destructor Destroy;
procedure DoQueryResultGlobal;
protected
procedure Execute; override;
end;
implementation
constructor TMySQL.Create;
begin
Database := TZMySqlDatabase.Create(nil);
Transact := TZMySqlTransact.Create(nil);
Query := TZMySqlQuery.Create(nil);
Transact.Database := Database;
Query.Database := DAtabase;
inherited Create(FALSE);
end;
procedure TMySQL.DoQueryResultGlobal;
begin
Form1.QueryGlobal:=
Query;
end;
procedure TMySQL.Execute;
const
WM_REFRESHAFTERQUERY= WM_USER+1001
begin
Query.Sql.Add('SELECT * FROM X WHERE a=b;');
Query.ExecSQL;
Synchronize(DoQueryResultGlobal);
PostMessage (
Handle, WM_REFRESHAFTERQUERY, 0, 0);
end;
destructor TMySQL.Destroy;
begin
Database.Free;
Transact.Free;
Query.Free;
inherited Destroy;
end;
end.