02.04.2016, 21:41
Problem has been fixed. Had to create new functions that would help fix /my/ problem only.
Those are adjusted to match my coding (tables and rows). It's suggested you modify them before you continue. The syntax is different as well, there's no more need to retrieve key as it's automatic now, just player name is required.
Could simply delete and modify main post, but as long as I didn't get any response, will be hard for others to do so as well. Hopefully this thread will help other people having the same issue.
pawn Код:
dbglobal bool:DB::SetLastIntEntry(table, const column[], value, const name[])
{
if (! DB::Get())
{
return false;
}
new globQuery[2000];
format(globQuery, sizeof globQuery, "UPDATE `%s` SET `%s` = '%d' WHERE `%s` = (SELECT `%s` FROM `%s` WHERE `Owner` = '%s' order by id desc LIMIT 1)", g_TableName[table], column, value, g_TableKey[table], g_TableKey[table], g_TableName[table], name);
print(globQuery);
new DBResult:result = db_query(g_Database, globQuery);
if (result)
{
db_free_result(result);
return true;
}
return false;
}
dbglobal bool:DB::SetLastFloatEntry(table, const column[], Float:value, const name[])
{
if (! DB::Get())
{
return false;
}
new globQuery[2000];
format(globQuery, sizeof globQuery, "UPDATE `%s` SET `%s` = '%f' WHERE `%s` = (SELECT `%s` FROM `%s` WHERE `Owner` = '%s' order by id desc LIMIT 1)", g_TableName[table], column, value, g_TableKey[table], g_TableKey[table], g_TableName[table], name);
print(globQuery);
new DBResult:result = db_query(g_Database, globQuery);
if (result)
{
db_free_result(result);
return true;
}
return false;
}
dbglobal bool:DB::SetLastStringEntry(table, const column[], const value[], const name[])
{
if (! DB::Get())
{
return false;
}
new globQuery[2000];
format(globQuery, globQuery, "UPDATE `%s` SET `%s` = '%q' WHERE `%s` = (SELECT `%s` FROM `%s` WHERE `Owner` = '%s' order by id desc LIMIT 1)", g_TableName[table], column, value, g_TableKey[table], g_TableKey[table], g_TableName[table], name);
print(globQuery);
new DBResult:result = db_query(g_Database, globQuery);
if (result)
{
db_free_result(result);
return true;
}
return false;
}
Код:
(table, const column[], value, const name[]) Table = table you're working on. column = column you want to update value = the value you want to update name = the player's name Example: DB::SetLastIntEntry(vTable, "Model", model, GetName(playerid)); This will set "Model" INT to model (script-defined), using vTable as a table and GetName as player name, in order to compare it with "Owner", column I use to identify vehicle owner in the code.