How extract id from 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: How extract id from database! (
/showthread.php?tid=589560)
How extract id from database! -
norton2 - 20.09.2015
Hey, when you insert a new car in the MySQL database, how I can extract the ID from database? (Use MYSQL R39 + ORM)
Код HTML:
mysql_format(MySQLCon, query, sizeof query, "INSERT INTO vehicles (Owner, Model, Color1, Color2, Value) VALUES('%d', '%d', '%d', '%d', '%d');", pInfo[playerid][pID], dmodelid[playerid], 1, 1, dprice[playerid]);
mysql_query(MySQLCon, query);
Re: How extract id from database! -
Vince - 20.09.2015
cache_insert_id()
Re: How extract id from database! -
norton2 - 20.09.2015
That's right?
Код HTML:
mysql_format(MySQLCon, query, sizeof query, "INSERT INTO vehicles (Owner, Model, Color1, Color2, Value) VALUES('%d', '%d', '%d', '%d', '%d');", pInfo[playerid][pID], dmodelid[playerid], 1, 1, dprice[playerid]);
mysql_query(MySQLCon, query);
new did = cache_insert_id();
printf("ID FROM DATABASE IS: %d", did);
Re: How extract id from database! -
xVIP3Rx - 20.09.2015
Yes.
Re: How extract id from database! -
Andre02 - 20.09.2015
Yes, but
pawn Код:
printf("ID FROM DATABASE IS: %d", cache_insert_id());
also works
Re: How extract id from database! -
norton2 - 20.09.2015
Thank you all!