logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
best data types for table

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Scripts and Modules
View previous topic :: View next topic  
Author Message
DM_Vecna



Joined: 10 Feb 2010
Posts: 37

PostPosted: Sun Apr 11, 2010 8:18    Post subject: best data types for table Reply with quote

I am building a new table in NWNX to replace the standard Bioware factions "table" that is found in the faction editor. My idea is to keep all of the factions in the Bioware editor at 0 and on module load adjust them to the persistent values of the NWNX table.

(In case you might be wondering why I am not storing any values in the Bioware faction editor it was easier for me to write the functions with a zero starting balance and I think it will be easier to adjust the values going forward in I only have to look in NWNX instead of the sum of two values stored in two locations. )

Back to the question at hand. I am not sure what would be the best data type to store the faction (1-100) values. Bear in mind I am new to NWNX MySQL and am using MySQL Workbench which is amazing when I can figure out how something works but there is not much documentation for absolute beginners.

Currently I made a table with the data type of "TEXT" for the faction values and a default of "NULL". But when I went in to add the actual starting values by hand using Workbench's "edit data" function it is not letting me adjust the NULL values. I am not sure if NULL was a bad choice and or if TEXT was the wrong choice for the data type. I tried typing in the MySQL statement:

"update `nwn`.`tbl_factions` set `hostile`='100' where `tbl_player_ID`='1' and`tbl_player_player_character`='hostile';

but when I now look at the table the value that is supposed to read 100 reads blob.

Thank you for any help!!!
Back to top
View user's profile Send private message Send e-mail
virusman



Joined: 30 Jan 2005
Posts: 1020
Location: Russia

PostPosted: Sun Apr 11, 2010 9:08    Post subject: Reply with quote

INT or TINYINT
See MySQL documentation on data types for more info.
_________________
In Soviet Russia, NWN plays you!
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
DM_Vecna



Joined: 10 Feb 2010
Posts: 37

PostPosted: Tue Apr 13, 2010 3:56    Post subject: Reply with quote

Thanks virusman;

After reviewing the documentation I think that tinyint will work best for my purposes.

When usign tinyint is there anything that you need to change in your nwscript to fetch it as it is an intiger? That was the only reason I was using a text datatype previously.
Back to top
View user's profile Send private message Send e-mail
virusman



Joined: 30 Jan 2005
Posts: 1020
Location: Russia

PostPosted: Tue Apr 13, 2010 6:29    Post subject: Reply with quote

int nValue = StringToInt(SQLGetData(1));
_________________
In Soviet Russia, NWN plays you!
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Scripts and Modules All times are GMT + 2 Hours
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, 2005 phpBB Group