MySQL Help
#1

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();
          }
     }
}
Reply
#2

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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)