Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Development

Development::Development Forum for development topics and for those interested in EQEMu development. (Not a support forum)

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 07-12-2011, 09:19 AM
Criimson
Hill Giant
 
Join Date: Sep 2006
Posts: 172
Default Reading data from DB

Hello everyone

So I am trying to learn how to read data from the DB and use it as a check in the bot ai.

I looked over other areas where data is being read and I thought I had it, but after trying several different ways I have decided to once again ask for some help.

Here is the code:

Code:
if(IsEffectInSpell(selectedBotSpell.SpellId, SE_Rune)){
			std::string errorMessage;
			char* Query = 0;
			char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE];
			MYSQL_RES* DatasetResult;
			MYSQL_ROW value;

			if(!database.RunQuery(Query, MakeAnyLenString(&Query, "SELECT values FROM bot_variables WHERE bot_variable = 'auto_rune';", TempErrorMessageBuffer, &DatasetResult))) {
				errorMessage = std::string(TempErrorMessageBuffer);
			}
						
			value = mysql_fetch_row(DatasetResult);
			int iAR = atoi(value[0]);
			if (iAR == 0){
				continue;
			}
		}
The table is very simple.
TABLE : bot_variables
Column 1: bot_variable
Column 2: values
Column 3: notes

I had very little trouble learning how to write to the DB, but extracting the information is giving me problems. From what I can tell the problem is arising from one of two things.
Option 1: values are stored as a text string and I am trying to use it as an int. However, I also tried running a check based on a string using if (sAR == '0'){ and that also didn't work.

Which leads me to think that
Option 2: I am not correctly grasping how
MYSQL_RES* DatasetResult;
MYSQL_ROW value;
mysql_fetch_row(DatasetResult);
works.

Any help would be appreciated. Good thing about programming is once you learn how something works you can do it as long as you keep practicing.

Criimson
Reply With Quote
 


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 03:44 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3