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 
 
pwobjdata - Whats it for?
Goto page Previous  1, 2
 
Post new topic   Reply to topic    nwnx.org Forum Index -> Database related
View previous topic :: View next topic  
Author Message
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Thu Jan 21, 2010 23:34    Post subject: how come?? Reply with quote

Quote:

o Got request (scorco): SELECT val FROM pwobjdata WHERE player='Baaleos' AND tag='Alisha Patson' AND name='AUCTION_ITEM'
o Got request: SELECT player FROM pwobjdata WHERE player='Baaleos' AND tag='Alisha Patson' AND name='AUCTION_ITEM'
o Got request (scorco): INSERT INTO pwobjdata (player,tag,name,val,expire) VALUES('Baaleos','Alisha Patson','AUCTION_ITEM',~s,0)
o Got request: select id from pwobjdata order by id desc limit 1
o Got request (scorco): SELECT val FROM pwobjdata WHERE player='Baaleos' AND tag='Alisha Patson' AND name='AUCTION_ITEM'
o Got request: SELECT player FROM pwobjdata WHERE player='Baaleos' AND tag='Alisha Patson' AND name='AUCTION_ITEM'
o Got request (scorco): INSERT INTO pwobjdata (player,tag,name,val,expire) VALUES('Baaleos','Alisha Patson','AUCTION_ITEM',~s,0)
o Got request: select id from pwobjdata order by id desc limit 1
o Got request (scorco): SELECT val FROM pwobjdata WHERE player='Baaleos' AND tag='Alisha Patson' AND name='AUCTION_ITEM'
o Got request: SELECT player FROM pwobjdata WHERE player='Baaleos' AND tag='Alisha Patson' AND name='AUCTION_ITEM'
o Got request (scorco): INSERT INTO pwobjdata (player,tag,name,val,expire) VALUES('Baaleos','Alisha Patson','AUCTION_ITEM',~s,0)
o Got request: select id from pwobjdata order by id desc limit 1
o Got request (scorco): SELECT val FROM pwobjdata WHERE player='Baaleos' AND tag='Alisha Patson' AND name='AUCTION_ITEM'
o Got request: SELECT player FROM pwobjdata WHERE player='Baaleos' AND tag='Alisha Patson' AND name='AUCTION_ITEM'
o Got request (scorco): INSERT INTO pwobjdata (player,tag,name,val,expire) VALUES('Baaleos','Alisha Patson','AUCTION_ITEM',~s,0)
o Got request: select id from pwobjdata order by id desc limit 1
o Got request (scorco): SELECT val FROM pwobjdata WHERE player='Baaleos' AND tag='Alisha Patson' AND name='AUCTION_ITEM'
o Got request: SELECT player FROM pwobjdata WHERE player='Baaleos' AND tag='Alisha Patson' AND name='AUCTION_ITEM'
o Got request (scorco): INSERT INTO pwobjdata (player,tag,name,val,expire) VALUES('Baaleos','Alisha Patson','AUCTION_ITEM',~s,0)
o Got request: select id from pwobjdata order by id desc limit 1
o Got request (scorco): SELECT val FROM pwobjdata WHERE player='Baaleos' AND tag='Alisha Patson' AND name='AUCTION_ITEM'
o Got request: SELECT player FROM pwobjdata WHERE player='Baaleos' AND tag='Alisha Patson' AND name='AUCTION_ITEM'
o Got request (scorco): INSERT INTO pwobjdata (player,tag,name,val,expire) VALUES('Baaleos','Alisha Patson','AUCTION_ITEM',~s,0)
o Got request: select id from pwobjdata order by id desc limit 1
o Got request (scorco): SELECT val FROM pwobjdata WHERE player='Baaleos' AND tag='Alisha Patson' AND name='AUCTION_ITEM'
o Got request: SELECT player FROM pwobjdata WHERE player='Baaleos' AND tag='Alisha Patson' AND name='AUCTION_ITEM'
o Got request (scorco): INSERT INTO pwobjdata (player,tag,name,val,expire) VALUES('Baaleos','Alisha Patson','AUCTION_ITEM',~s,0)
o Got request: select id from pwobjdata order by id desc limit 1




I've been testing the SetPersistentObject functions, ive noticed something weird.


I modified the pwobjdata table, to add an id field.
After inserting the object, I am performing a select id from pwobjdata order by id desc limit 1 query.

When I do this manually, it retuns the id number of the last item to be stored.
However, when I do this from nwnx, the query doesnt return anything - the odbc logs look weird, they dont show any message indicating a return.

Code looks like this


Code:

//auction_inc file contents

int GetLatestID()
{
int iNum = -1;
 string sQuery = "select id from pwobjdata order by id desc limit 1"; // gets the id number for the most recent item added.
 SQLExecDirect(sQuery);
 if(SQLFetch() == SQL_SUCCESS)
    {
     iNum = StringToInt(SQLGetData(1));
    }
return iNum;

}



void StoreItemToBeSold()
{
 object oChest = OBJECT_SELF;
 object oItem = GetFirstItemInInventory(oChest);
 object oUser = GetLastClosedBy();
 SetPersistentObject(oUser, "AUCTION_ITEM",oItem);

 int iID = GetLatestID();
 AssignCommand(oUser,SpeakString("ID is "+IntToString(iID)));

 DelayCommand(1.00,DestroyObject(oItem));
}
================


The on Close event of a chest
#include "auction_inc"
void main()
{
StoreItemToBeSold();
}





The id my character keeps speaking is -1 - showing that its not getting any reply from the database query for the object id.

Any help would be appreciated.
Back to top
View user's profile Send private message
Fireboar



Joined: 17 Feb 2008
Posts: 323

PostPosted: Sat Jan 23, 2010 3:34    Post subject: Reply with quote

Is your ID field set to be an auto increment primary key? If not, you'll need to make it so.
Back to top
View user's profile Send private message
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Sat Jan 23, 2010 12:07    Post subject: Reply with quote

Yeah the Id field is auto increment, but the way the logs look, it's like it's getting no reply from the server at all. No return bytes message
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Database related All times are GMT + 2 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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