BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

MySQL Boolean problem (continued)

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers)
View previous topic :: View next topic  
Author Message
donlelel
Guest





PostPosted: Thu Jul 21, 2005 3:56 pm    Post subject: MySQL Boolean problem (continued) Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.