My console stop right after mysql_query(query)
#9

Quote:
Originally Posted by Misiur
Посмотреть сообщение
Query is the heaviest thing your gamemode can do (big simplification, but whatever). The less queries fired, the better. With a single query you can fetch all results from multiple various tables (SQL is powerful!). So, instead using one query per house, run one query for all houses, and then map results to your array.

pawn Код:
stock MySQL_LoadHouse()
{
    new
        str[512]
    ;

    mysql_query("SELECT * FROM houses");
    mysql_store_result();
    while(mysql_fetch_row(str,"|")) {
        //Do something
    }
    mysql_free_result();
}
Also, unthreaded queries will pause your script execution, until the query is finished, that's why you should use threaded queries (available in most of MySQL plugins). Search around forum for threaded queries tutorial, or better yet, use ORM system from BlueG plugin.


Keep in mind, that database id shouldn't be your array index.
And, in your example, how can I add a value to a certain house id? Because, when I add a value to a matrix, I have hid (house id) there. So the house with that id will receive that info.

I mean I am not sure about that query you've posted. Can you explain how to adapt that in my case?

Код:
mysql_fetch_field("id",savingstring);
HouseInfo[hid][hId]=strval(savingstring);
mysql_fetch_field("owner",savingstring);
strins(HouseInfo[hid][hOwner],savingstring,1);
mysql_fetch_field("level",savingstring);
HouseInfo[hid][hLevel]=strval(savingstring);
Anyway, thank you for your explanation till' now. I am not so experienced.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)