SA-MP Forums Archive
MySQL Inserting... - 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 Inserting... (/showthread.php?tid=535837)



MySQL Inserting... - Runn3R - 06.09.2014

Well i had to do this because of the error input size too long so i needed to ask...
Is this the best way to do this? I mean is there any better way doing this because it doesn't seem perfect so if you guys can help me out and tell me is it good or bad..

Код:
new query[512], query2[512];
	mysql_format(mysql, query, sizeof(query), "INSERT INTO `"TABLE_HOUSES"` (`Price`, `Owned`, `Owner`, `EntX`, `EntY`, `EntZ`, `ExX` ,`ExY`, `ExZ`, `VirWorld`, `Int`)");
	mysql_format(mysql, query2, sizeof(query2), "VALUES ('%d', '%d', '%s', '%f', '%f', '%f', '%f', '%f', '%f', '%d', '%d')",\
 	HouseInfo[HouseID][Price], HouseInfo[HouseID][Owned], HouseInfo[HouseID][Owner], HouseInfo[HouseID][EntX], HouseInfo[HouseID][EntY], HouseInfo[HouseID][EntZ], HouseInfo[HouseID][ExX], HouseInfo[HouseID][ExY],\
  	HouseInfo[HouseID][ExZ], HouseInfo[HouseID][VirtualWorld], HouseInfo[HouseID][Interior]);
    strcat(query, query2);
	mysql_query(mysql, query);
Thanks.


Re: MySQL Inserting... - AMouldyLemon - 06.09.2014

Is this creating a house?


Re: MySQL Inserting... - Runn3R - 06.09.2014

Yeah.

Do you think that the format is good or bad?
I mean didn't ever used strcat but i had to because the line was too long tho..


Re: MySQL Inserting... - AMouldyLemon - 06.09.2014

pawn Код:
new query[1024];
format(query, sizeof(query), "INSERT INTO `HOUSES` (Price, Owned, Owner, etc. ,) VALUES ('%d', '%d', '%s)",
HouseInfo[HouseID][Price],
HouseInfo[HouseID][Owned],
HouseInfo[HouseID][Owner],
etc.

mysql_query(mysql, query);
I would maybe do it like that.


Re: MySQL Inserting... - Runn3R - 06.09.2014

OMG i forgot about this LOL Thanks man LMAO...

Rep+