 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
donlelel Guest
|
Posted: Thu Jul 21, 2005 3:56 pm Post subject: MySQL Boolean problem (continued) |
|
|
Hi,
Just to propose a solution (I couldnt add it unfortunately to the old
thread, thread found by me while searching to see what others did to
solve the problem).
So, what to do when having to deal with boolean fields in MySql
(implemented as tiny int or whatever)? What I've done is I just created
a new DB.pas unit , added it to my project and modified inside the
original DB.pas unit the TSmallintField class , adding 2 methods :
function GetAsBoolean: Boolean; override;
procedure SetAsBoolean(Value: Boolean); override;
The implementation for them is
{--------------------------------------------------------------------------------}
{$IFDEF MAP_FIELD_BOOL}
function TSmallintField.GetAsBoolean: Boolean;
begin
if (AsInteger=0) or IsNull then
Result := False
else
Result := True;
end;
{--------------------------------------------------------------------------------}
procedure TSmallintField.SetAsBoolean(Value: Boolean);
begin
if Value then
AsInteger:=1
else
AsInteger:=0;
end;
{--------------------------------------------------------------------------------}
{$ENDIF}
It works for me. It's much faster than having to replace a whole bunch
of TDBCheckBox controls etc.
Anyone has a better idea?
Best,Don
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|