MySQL - Saving an array with multiple integer values? - 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 - Saving an array with multiple integer values? (
/showthread.php?tid=432747)
MySQL - Saving an array with multiple integer values? [Resolved] -
Hawkseye - 24.04.2013
Right, so I'm wanting to save specific item ID's contained in an inventory using an integer array. Pretty simple.. although this ain't working. At all. I've only just converted over to using MySQL from dini so I'm not very familiar with php. Is this even possible with MySQL? Any help would be quite wonderful.
Код:
new cnt;
while(cnt <= 35) //Max Business inventory slots
{
format(query, sizeof(query),"UPDATE `businesses` SET `Inventory[%d]`= %d WHERE `SQLID`= %d ;",cnt, -1 ,i);
mysql_query(query);
cnt++;
}
SQL Error log:
Код:
[00:12:12] CMySQLHandler::Query(UPDATE `businesses` SET `Inventory (35)`= '-1' WHERE `SQLID`=2 ;) - An error has occured. (Error ID: 1054, Unknown column 'Inventory[35]' in 'field list')
[00:12:12] >> mysql_query( Connection handle: 1 )
I've considered just creating a new column for each of the 35 values but I appreciate things being more organized if I can help it.
Re: MySQL - Saving an array with multiple integer values? -
mastermax7777 - 24.04.2013
faill.. learn mysql and come back later u cant have array like that lol
Re: MySQL - Saving an array with multiple integer values? -
Vince - 24.04.2013
Indeed, create more tables.
Re: MySQL - Saving an array with multiple integer values? -
Hawkseye - 24.04.2013
Alright, thanks for the response guys.
-Resolved.
Re: MySQL - Saving an array with multiple integer values? -
Pottus - 24.04.2013
You could also do this...
Код:
format(query, sizeof(query),"UPDATE `businesses` SET `Inventory`= %d %d %d %d WHERE `SQLID`= %d ;",
cnt[0], cnt[1], cnt[2], cnt[3], i);