Greetings,
Sorry if this is the wrong place to post this(I got no answer yet on NWNX forums).
I'm currently debugging a custom DB item storage system, storing and retrieving items from a NPC wich in turn is stored in a MySQL table. The table's field used to store the NPC is BLOB type. The Get and Set functions posted below do not work, however. I mean, no storage or retrieval is currently possible. Anyone has an idea as to where the syntax error(s) might be?
void SetPersistentObject(object oPC, object oObject)
{
string sKey = GetPCPublicCDKey(oPC, TRUE);
string sSQL = "INSERT INTO bank(cdkey,xp,gold,storer) VALUES('" + sKey + "','0','0',%s) ON DUPLICATE KEY UPDATE storer=%s";
SetLocalString(GetModule(), "NWNX!ODBC!SETSCORCOSQL", sSQL);
StoreCampaignObject("NWNX", "-", oObject);
}
object GetPersistentObject(object oPC, object oOwner)
{
string sKey = GetPCPublicCDKey(oPC, TRUE);
string sSQL = "SELECT storer FROM bank WHERE cdkey='" + sKey + "'";
SetLocalString(GetModule(), "NWNX!ODBC!SETSCORCOSQL", sSQL);
if(!GetIsObjectValid(oOwner)) oOwner = oPC;
return RetrieveCampaignObject("NWNX", "-", GetLocation(oOwner), oOwner);
}
My odbc log:
o Got request (scorco): SELECT storer FROM bank WHERE cdkey='Q7KUVYJJ'
o Got request (scorco): INSERT INTO bank(cdkey,xp,gold,storer) VALUES('Q7KUVYJJ','0','0',~s) ON DUPLICATE KEY UPDATE storer=~s
! SQL Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
o Got request (scorco): SELECT storer FROM bank WHERE cdkey='Q7KUVYJJ'
o Got request (scorco): INSERT INTO bank(cdkey,xp,gold,storer) VALUES('Q7KUVYJJ','0','0',~s) ON DUPLICATE KEY UPDATE storer=~s
! SQL Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
Thank you very much in advance
Kato
Modifié par Kato_Yang, 17 juillet 2011 - 08:38 .