Not getting value from MySQL Database
#1

Hey!

I'm having issue getting BizID value from database right after business is saved.

https://pastebin.com/9HNaHGUA

Help appreciated !
Reply
#2

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();
}
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)