MySQL Help - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: MySQL Help (
/showthread.php?tid=276485)
MySQL Help -
AustinJ - 14.08.2011
I have a table in the MySQL database called "factions' it stores all the faction variables. Is there a way I could load all these variables in one query? Here is what I need to put the variables into:
Код:
enum fInfo
{
File[14],
Name[256],
Rank1[32],
Rank2[32],
Rank3[32],
Rank4[32],
Rank5[32],
Rank6[32],
Rank7[32],
Rank8[32],
Rank9[32],
Rank10[32],
Float:ExtX,
Float:ExtY,
Float:ExtZ,
Float:ExtA,
Float:IntX,
Float:IntY,
Float:IntZ,
Float:IntA,
Interior,
World
}
new FactionInfo[FACTION_MAX][fInfo];
Then I have the public to load factions:
Код:
LoadFaction()
{
for(new i = 0; i < FACTION_MAX; i++)
{
// Place to load crap...
}
}
Under the callback currently I have:
Код:
public LoadFactions()
{
for(new i = 0; i < FACTION_MAX; i++)
{
new query[256];
format(query, 256, "SELECT * FROM factions WHERE ID = '%i' LIMIT 1", i);
mysql_store_result();
while(mysql_retrieve_row())
{
mysql_fetch_field_row(FactionInfo[i][Name], "Name");
mysql_fetch_field_row(FactionInfo[i][Rank1], "Rank1");
mysql_fetch_field_row(FactionInfo[i][Rank2], "Rank2");
mysql_fetch_field_row(FactionInfo[i][Rank3], "Rank3");
mysql_fetch_field_row(FactionInfo[i][Rank4], "Rank4");
mysql_fetch_field_row(FactionInfo[i][Rank5], "Rank5");
mysql_fetch_field_row(FactionInfo[i][Rank6], "Rank6");
mysql_fetch_field_row(FactionInfo[i][Rank7], "Rank7");
mysql_fetch_field_row(FactionInfo[i][Rank8], "Rank8");
mysql_fetch_field_row(FactionInfo[i][Rank9], "Rank9");
mysql_fetch_field_row(FactionInfo[i][Rank10], "Rank10");
mysql_free_result();
}
}
}
Re: MySQL Help -
[HiC]TheKiller - 14.08.2011
I'm not sure how your current code works when you don't even have mysql_query but anyway, try this.
pawn Код:
public LoadFactions()
{
new uptoid;
mysql_query("SELECT * FROM factions");
mysql_store_result();
while(mysql_retrieve_row())
{
mysql_fetch_field_row(FactionInfo[uptoid][Name], "Name");
mysql_fetch_field_row(FactionInfo[uptoid][Rank1], "Rank1");
mysql_fetch_field_row(FactionInfo[uptoid][Rank2], "Rank2");
mysql_fetch_field_row(FactionInfo[uptoid][Rank3], "Rank3");
mysql_fetch_field_row(FactionInfo[uptoid][Rank4], "Rank4");
mysql_fetch_field_row(FactionInfo[uptoid][Rank5], "Rank5");
mysql_fetch_field_row(FactionInfo[uptoid][Rank6], "Rank6");
mysql_fetch_field_row(FactionInfo[uptoid][Rank7], "Rank7");
mysql_fetch_field_row(FactionInfo[uptoid][Rank8], "Rank8");
mysql_fetch_field_row(FactionInfo[uptoid][Rank9], "Rank9");
mysql_fetch_field_row(FactionInfo[uptoid][Rank10], "Rank10");
uptoid++;
}
mysql_free_result();
return 1;
}