MySQL question tquery - 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 question tquery (
/showthread.php?tid=580819)
MySQL question tquery -
Dan. - 08.07.2015
Hi..
I'm using mysql_tquery to INSERT a new base into the database that I have just created. I then wish to assign the inserted values to the base Enums aswell.. but I do not know the base ID that gets auto incremented.
How should I get that ID so I know the base ID (BaseInfo[baseid][bOwner] for example). I thought maybe to use the callback with tquery and then I can do 'cache_insert_id();'?
But I am getting the player position when he types the CMD.. does it affect something if I get the player position in the query callback?
Re: MySQL question tquery -
dusk - 08.07.2015
cache_insert_id will return the value from your auto_incremented column.
Yes you can get the players position in mysql callback function, you can do whatever you want there. It's the same as any other function.
Re: MySQL question tquery -
Vince - 08.07.2015
Quote:
Originally Posted by Dan.
I thought maybe to use the callback with tquery and then I can do 'cache_insert_id();'
|
Exactly. You can pass the position to the callback or fetch it in the callback itself. I don't think it really matters where you decide to fetch it as inserting a single new record happens almost instantly.
Edit: slightly slow.