10.09.2010, 17:27
sqlite_highest_field.
So basically SQLite has no function similar to the mysql function mysql_insert_id(), sqlite_highest_field will emulate the function returning the latest ID for example which we would assume would be the highest ID.
Example Usage:
So basically SQLite has no function similar to the mysql function mysql_insert_id(), sqlite_highest_field will emulate the function returning the latest ID for example which we would assume would be the highest ID.
Example Usage:
pawn Код:
format(query, sizeof(query), "Your character ID = %d.", sqlite_highest_field(USERDB, "id", "Character"));
SendClientMessage(playerid, COLOR_WHITE, query);
pawn Код:
stock sqlite_highest_field(DB:db, fieldname[], tablename[])
{
new query[128], DBResult:qresult, id = -1, queryresult[128];
format(query, sizeof(query), "SELECT max( `%s` ) FROM `%s`", fieldname, tablename);
qresult = db_query(db, query);
db_get_field(qresult,0,queryresult,128);
id = strval(queryresult);
db_free_result(qresult);
return id;
}