[MYSQL][FIXED]Getting all rows from a table -
Webghost - 30.10.2011
To fix the problem:
http://pastebin.com/RPKQzz0j
________________________________________________
I am currently trying to rebuild a Housing system.
The system works very well except for 1 thing.
On filterscriptinit should load all the houses at once, then create them 1 by 1.
I have no clue on what to do on this issue, reading a table to expect only 1 row i know by heart, receiving multiple rows, there i am lost.
This is what i've got, it seems to read only 1 row:
>>> ERROR MESSAGE:
[14:44:55] Filterscript 'housesystem.amx' loaded.
[14:44:55] [MySQL] Error (0): Function: mysql_store_result called when no result stored.
[14:44:55] Number of created Houses: 1
>>> PASTEBIN VERSION:
http://pastebin.com/ADCHrZfc
pawn Код:
#define THREAD_LOADHOUSES 100
public OnFilterScriptInit()
{
//MySQL Connection
MySQLConnect(MySQL_Hostname, MySQL_Username, MySQL_Database, MySQL_Password, MySQL_Connection, true);
//Load Houses
mysql_query("SELECT * FROM `houses`", THREAD_LOADHOUSES, -1);
return 1;
}
public OnMysqlQuery(resultid, spareid, MySQL:handle)
{
switch(resultid)
{
case THREAD_LOADHOUSES:
{
mysql_store_result(handle);
new HouseCount = 0, MySQL_Load[150];
while(mysql_fetch_row(MySQL_Load, "|", handle))
{
new ID, Owner[24], HName[128], HPass[128], Float:X, Float:Y, Float:Z, Float:eX, Float:eY, Float:eZ, Float:eA, Doors, InteriorModel, Cost;
sscanf(MySQL_Load, "p<|>ds[24]s[128]s[128]fffffffddd",
ID,
Owner,
HName,
HPass,
X,
Y,
Z,
eX,
eY,
eZ,
eA,
Doors,
InteriorModel,
Cost);
CreateHouse(true, ID, Owner, HName, HPass, X, Y, Z, eX, eY, eZ, eA, Doors, InteriorModel, Cost);
HouseCount ++;
}
printf("Number of created Houses: %d", HouseCount);
mysql_free_result(handle);
}
}
return 1;
}
Re: [MYSQL]Getting all rows from a table -
Webghost - 30.10.2011
bump
Re: [MYSQL]Getting all rows from a table -
skullmuncher1337 - 30.10.2011
Use [ pawn ] tags!
Приносим вам свои извинения, но у нас на форуме пользователи могут отправлять сообщения не чаще, чем раз в 120 секунд. Попробуйте отправить своё сообщение через 10 секунд.
Re: [MYSQL]Getting all rows from a table -
Webghost - 30.10.2011
bumping again
Re: [MYSQL]Getting all rows from a table -
Joe Staff - 30.10.2011
Bump once every 24 hours.
As far as I know, all MySQL plugins come with a next_row function, you call this to receive the next route of your query result.
Create a while loop that runs so long as next_row returns an appropriate row.
Re: [MYSQL]Getting all rows from a table -
Webghost - 31.10.2011
Bumb again then

By the way, i had no luck using this 'next_row'
Re: [MYSQL]Getting all rows from a table -
Webghost - 31.10.2011
I have fixed the problem.
I used the way this guy loads trough properties:
http://pastebin.com/RPKQzz0j
Re: [MYSQL]Getting all rows from a table -
Treyvan - 31.10.2011
Sometimes I feel like I'm the only one that uses,
pawn Код:
while(mysql_fetch_row(resultline,"|") == 1)
{
// do shit here.
}
in sql queries that load entire tables.