02.03.2018, 18:29
I am using BlueG's MySQL Plugin Latest Version.
I am trying to load houses from the database.
Code:
It always shows 'Loaded 1 houses', though there are 5 houses in my database. Is this the correct way to retrieve multiple rows? Please help! I am stuck from three days.
I am trying to load houses from the database.
Code:
Код:
stock LoadHouses()
{
new query[256];
mysql_format(g_SQL, query, sizeof(query), "SELECT * FROM `houses` WHERE `HouseStatus` = 1");
mysql_tquery(g_SQL, query, "LoadHousesCb", "");
}
public LoadHousesCb()
{
new rows, fields, string[512];
cache_get_row_count(rows);
cache_get_field_count(fields);
if(rows)
{
new temphid, tempowner, tempprice, tempinterior, Float:tempx, Float:tempy, Float:tempz, templock, templevel, tempstatus;
for(new x = 0; x < cache_num_rows(); x++)
{
cache_get_value_name_int(x, "HouseID", temphid);
House[houses][HouseID] = temphid;
cache_get_value_name(x, "HouseOwner", "tempowner", sizeof(tempowner));
House[houses][HouseOwner] = tempowner;
cache_get_value_name_int(x, "HousePrice", tempprice);
House[houses][HousePrice] = tempprice;
cache_get_value_name_int(x, "HouseInterior", tempinterior);
House[houses][HouseInterior] = tempinterior;
cache_get_value_name_float(x, "HouseEntranceX", tempx);
House[houses][HouseEntranceX] = tempx;
cache_get_value_name_float(x, "HouseEntranceY", tempy);
House[houses][HouseEntranceY] = tempy;
cache_get_value_name_float(x, "HouseEntranceZ", tempz);
House[houses][HouseEntranceZ] = tempz;
cache_get_value_name_int(x, "isLocked", templock);
House[houses][isLocked] = templock;
cache_get_value_name_int(x, "HouseLevel", templevel);
House[houses][HouseLevel] = templevel;
cache_get_value_name_int(x, "HouseStatus", tempstatus);
House[houses][HouseStatus] = tempstatus;
}
houses++;
}
printf("Loaded %d houses.", houses);
}


