SA-MP Forums Archive
MySQL get the id of last affected row - 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: MySQL get the id of last affected row (/showthread.php?tid=634364)



MySQL get the id of last affected row - AndreiWow - 17.05.2017

How can you get the ID of last updated row in pawn?


Re: MySQL get the id of last affected row - Vince - 17.05.2017

If the query was an insert then you use cache_insert_id(). Otherwise it's not possible.


Re: MySQL get the id of last affected row - 1nspire - 17.05.2017

And what if we do the following:

PHP код:
mysql_format(Databasestringsizeof(string), "SELECT * FROM `GodDamnAssetsThatImStuckOn` WHERE `Active` = 0 LIMIT 1"); 
How do we go about getting the ID of that row if we need it?


Re: MySQL get the id of last affected row - AndreiWow - 17.05.2017

Quote:
Originally Posted by Vince
Посмотреть сообщение
If the query was an insert then you use cache_insert_id(). Otherwise it's not possible.
Then probably only way is to have a column called "pending" and once I update that row I set it to 1 then a SELECT query WHERE pending = 1, get the ID use it and then UPDATE the row again to set the pending column back to 0..

Any better way?