18.10.2014, 15:18
Queria saber se tem como eu pegar todas essas linhas em uma consulta sу, sem ter que criar uma Call para todas as linhas separadamente.
new query[1024];
format(query, sizeof(query), "SELECT * FROM `tabela` WHERE `id` = '%d'", 1);
mysql_function_query(connect, query, true, "Call", "");
forward Call();
public Call()
{
new linhas, campos;
cache_get_data(linhas, campos, connect);
if(linhas)
{
new query[1024], string[128];
cache_get_field_content(0, "mapname", query, connect);
format(string, 128, "mapname %s", query);
SendRconCommand(string);
}
return 1;
}
eu criei um cуdigo bem rapidinho aqui pra dar de exemplo
pawn Код:
|
public OnGameModeInit() {
for(new y = 0; y <= 4; y++){
mysql_format(conexгo,string,sizeof(string),"SELECT * FROM `nometabela` WHERE `id` = '%i'",y);
mysql_tquery(conexгo, string, "Nome_Callback", "");
}
return true;
}
forward Nome_CallBack();
public Nome_CallBack(){
new rows,fields;
cache_get_data(rows, fields);
if(cache_num_rows() == 1){
new x1[130],y2[130],z3[130];
cache_get_field_content(0, "configuracao-key", x1);
cache_get_field_content(0, "configuracao-Valor", y2);
cache_get_field_content(0, "UltimaAlteracao", z3);
printf("Configuraзгo Key = %s Configuraзгo Valor = %s Ultima Alteraзгo = %s",x1,y2,z3);
}
return true;
}
new query[1024];
format(query, sizeof(query), "SELECT * FROM `tabela` WHERE `id` = '%d'", 1);
mysql_function_query(connect, query, true, "Call", "");
forward Call();
public Call()
{
new linhas, campos;
cache_get_data(linhas, campos, connect);
if(linhas)
{
new query[1024], string[128];
cache_get_field_content(0, "mapname", query, connect);
format(string, 128, "mapname %s", query);
SendRconCommand(string);
cache_get_field_content(0, "hostname", query, connect);
format(string, 128, "hostname %s", query);
SendRconCommand(string);
cache_get_field_content(0, "weburl", query, connect);
format(string, 128, "weburl %s", query);
SendRconCommand(string);
cache_get_field_content(0, "gamemodetext", query, connect);
format(string, 128, "gamemodetext %s", query);
SendRconCommand(string);
}
return 1;
}