Not getting value from MySQL Database - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Not getting value from MySQL Database (
/showthread.php?tid=659148)
Not getting value from MySQL Database -
NoteND - 25.09.2018
Hey!
I'm having issue getting BizID value from database right after business is saved.
https://pastebin.com/9HNaHGUA
Help appreciated !
Re: Not getting value from MySQL Database -
Calisthenics - 25.09.2018
BizID column must be set as AUTO INCREMENT. After an INSERT query, there is a function called cache_insert_id which retrieves the value generated by AI column.
Your code executes a non-threaded query and you will need to free the memory if you are going to retrieve:
pawn Код:
new Cache: cache_id = mysql_query(Database, query);
bInfo[id][BizID] = cache_insert_id();
cache_delete(cache_id);
to avoid memory leak.
Why do you not use threaded queries? It is advised to, most of the times.
pawn Код:
mysql_tquery(Database, query, "OnBusinessCreate", "d", id);
// pass `playerid` if you send message to the creator of the business
pawn Код:
forward OnBusinessCreate(business_id);
public OnBusinessCreate(business_id)
{
bInfo[business_id][BizID] = cache_insert_id();
}