Problem about id order mysql - 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: Problem about id order mysql (
/showthread.php?tid=561299)
Problem about id order mysql -
Metharon - 02.02.2015
How can i get the last id ... to make them 1, 2 , 3 , 4
My code
pawn Код:
format(szQuery, 500, "INSERT INTO `accounts` (Name,Password) VALUES ('%s','%s')", GetName(playerid), PasswordInserted[playerid]);
mysql_tquery(SQL, szQuery, "", "");
Re: Problem about id order mysql -
WeirdestYeti - 02.02.2015
If you want to get the ID when you instered new row, use mysql_insert_id.
Use it after query, this function gets LAST inserted AI id.
Re: Problem about id order mysql -
Metharon - 02.02.2015
I don't know how to use it..
Re: Problem about id order mysql -
WeirdestYeti - 02.02.2015
My code example.
Quote:
format(string, sizeof(string), "INSERT INTO `furniture` (`ID`) VALUES(%d)", HouseInfo[houseid][id]);
mysql_query(string);
OnFurnitureCreated(idz);
|
And OnFurnitureCreated runs.
Quote:
forward OnFurnitureCreated(furnitureid);
public OnFurnitureCreated(furnitureid)
{
FurnitureData[furnitureid][furnitureID] = mysql_insert_id();
Furniture_Save(furnitureid);
return 1;
}
|
Re: Problem about id order mysql -
Metharon - 02.02.2015
when i' using mysql_insert_id = i get error which one said don't exist the param..
and if i use cache_insert_id = i get in mysql_log "no active cache"