Raised This Month: $51 Target: $400
 12% 

SQL_FetchBool?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Dr. Greg House
Professional Troll,
Part-Time Asshole
Join Date: Jun 2010
Old 04-11-2012 , 11:29   SQL_FetchBool?
Reply With Quote #1

Following database:

Code:
SQL_FastQuery(db, "CREATE TABLE IF NOT EXISTS Preferences (steamid TEXT PRIMARY KEY, lausch BOOLEAN, listen BOOLEAN);");
How can I fetch the result's values? Does SQL_FetchInt() return "0" or "1"? And if so, can I assign them to a bool directly, or do I have to parse them?

Thanks in advance!
House

Last edited by Dr. Greg House; 04-11-2012 at 11:29.
Dr. Greg House is offline
napalm00
Veteran Member
Join Date: Jun 2011
Location: Italy, sadly
Old 04-11-2012 , 12:25   Re: SQL_FetchBool?
Reply With Quote #2

SQL_FetchInt is the one you have to use, it'll return 1 if the boolean is set to true, 0 if it's set to false.
If you really wanted to have the results as booleans (seems useless to me, but whatever) you could do
PHP Code:
new bool:bBool SQL_FetchInt(dbhandleslot); 
__________________
napalm00 is offline
Dr. McKay
Sir Dr. SourceMod Plugin Approver Esq. Ltd. M.D. PhD
Join Date: Aug 2011
Location: Atlantis
Old 04-11-2012 , 22:31   Re: SQL_FetchBool?
Reply With Quote #3

Yeah, SQL doesn't support booleans. Most of the time, for a boolean, a tinyint(1) field is used, containing 1 or 0. Therefore, there's no SQL_FetchBool.

napalm's suggestion ought to work, or you can just do if(SQL_FetchInt(....) == 1)
__________________
Dr. McKay is offline
necavi
Veteran Member
Join Date: Sep 2010
Old 04-11-2012 , 23:12   Re: SQL_FetchBool?
Reply With Quote #4

It does support BIT, if I remember correctly.
necavi is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:38.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode