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 
 
MySQL returning only 1 row

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Database related
View previous topic :: View next topic  
Author Message
Kato



Joined: 05 Mar 2010
Posts: 47

PostPosted: Mon May 02, 2011 21:26    Post subject: MySQL returning only 1 row Reply with quote

Greetings,

I'm currently coding a guild system for my NWN PW, storing all persistent data in a custom MySQL database. The guild infos are displayed to players via a dynamic dialog, wich sends many different queries, all working fine, except for this one:

string sSQL = "SELECT DISTINCT tag FROM players WHERE guild='" + IntToString(nGuild) + "'";
SQLExecDirect(sSQL);
while(SQLFetch() == SQL_SUCCESS)
{
AddStringElement(SQLGetData(1), PAGE2C, oPC);
}

The tag field is a VARCHAR64, holding the value returned by GetPCPlayerName(); both the odbc log and the dialog display a single row. So, I have raised the buffer from 8 * 128 to 128 * 128, trying each step on the way(16, 32 etc...). Still, only one row is displayed(!?)

Any help would be greatly appreciated, thanks in advance!!!!!!!!
Back to top
View user's profile Send private message Send e-mail
MaxRock



Joined: 24 Jan 2008
Posts: 196

PostPosted: Tue May 03, 2011 18:16    Post subject: Reply with quote

Just for debugging, change AddStringEntry to WriteTimestampedLogEntry; so you can rule out the zdialog scripts.
Put the query into mysql directly (e.g.: mysql query browser) and see if that returns more.
Can you post the odbc log?
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Kato



Joined: 05 Mar 2010
Posts: 47

PostPosted: Tue May 03, 2011 20:21    Post subject: Reply with quote

Okay. After testing the query in the query browser, it returns the correct answer, just like WriteTimestampedLogEntry, wich appends these lines to nwnx-odbc.txt:

o Got request: SELECT DISTINCT tag FROM players WHERE guild='1'
o Sent response (7 bytes): Rastin1
o Sent response (8 bytes): ZenBlade
o Sent response (7 bytes): Jearld1
o Sent response (8 bytes): Anaknaej
o Sent response (7 bytes): Rashtin
o Sent response (8 bytes): laskoski
o Sent response (14 bytes): Chaos Maverick
o Sent response (0 bytes):

Also, SendMessageToPC(oPC, SQLGetData(1)) returns the correct answer, wich leads me to think that my problem probably comes from my zdialog scripts. I'll be back with the solution when I find it, thank you for your help, MaxRock. Smile
Back to top
View user's profile Send private message Send e-mail
Kato



Joined: 05 Mar 2010
Posts: 47

PostPosted: Tue May 03, 2011 21:03    Post subject: Reply with quote

Okay, I have found it. There was another call to SQLFetch() on the call stack. Sorry, I feel dumb... Embarassed
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Database related 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