Threaded queries
#1

I just started working with threaded queries because they say that it prevents server from lagging because of the Query.
pawn Code:
public OnQueryFinish(query[], resultid, extraid, connectionHandle)
{
      new connectionhandle = connectionHandle;
      switch(resultid)
      {
                case THREAD_FACTION_UCP:
                {


                    mysql_store_result();

                    if(mysql_num_rows() == 0)
                    {
                        SendClientMessage(extraid, COLOR_FACTION, "You don't have any faction members!");
                        mysql_free_result();
                        return 1;
                    }

                    string = " ";
                    ProductList = " ";

                    new LastSeen[20];
                    new Rankk;
                    new MemberCount;
                    new CharacterName[24];
                    new RankkName[24];
                    new MemberID;


                    AddDListItem(extraid, "Member Name\t\tRank\t\t\tLast Seen", 10000, 0);


                    while(mysql_fetch_row_format(line,"|"))
                    {
                        MemberCount ++;

                        sscanf(line, "p<|>{iffiiiiiii}i{ii}s[24]i{ffffii}s[20]", Rankk, CharacterName, MemberID, LastSeen );

                        switch(Rankk)
                        {
                            case 1: format(RankkName, 24, "%s", FactionInfo[connectionhandle][Rank1]);
                            case 2: format(RankkName, 24, "%s", FactionInfo[connectionhandle][Rank2]);
                            case 3: format(RankkName, 24, "%s", FactionInfo[connectionhandle][Rank3]);
                            case 4: format(RankkName, 24, "%s", FactionInfo[connectionhandle][Rank4]);
                            case 5: format(RankkName, 24, "%s", FactionInfo[connectionhandle][Rank5]);
                        }


                        format(ProductList, sizeof(ProductList), "%s\t\t%s\t\t%s", CharacterName, RankkName, LastSeen);
                        AddDListItem(extraid, ProductList, 0, MemberID);


                    }

                    format(string, sizeof(string), "Members: %i", MemberCount);
                    ShowPlayerDList(extraid, 5024, string, "Select", "Exit");

                    mysql_free_result();
                    dialog_free_items();
                }
     }
     return 1;
}
pawn Code:
stock ShowFactionMembers(playerid, factionid)
{

    format(string, sizeof(string), "SELECT * FROM characters WHERE faction = '%d'", factionid);
    mysql_query(string, THREAD_FACTION_UCP, playerid, factionid);

}
Code:
[16:34:50] OnQueryFinish("SELECT * FROM characters WHERE faction = '1'",1) - Called.

[16:34:50] >> mysql_store_result( Connection handle: 1 )

[16:34:50] CMySQLHandler::StoreResult() - No data to store.

[16:34:50] >> mysql_num_rows( Connection handle: 1 )

[16:34:50] CMySQLHandler::NumRows() - You cannot call this function now. (Reason: Dead Connection)

[16:34:50] >> mysql_free_result( Connection handle: 1 )

[16:34:50] CMySQLHandler::FreeResult() - The result is already empty.

[16:34:57] >> mysql_query( Connection handle: 1 )

[16:34:57] CMySQLHandler::Query(SELECT * FROM characters WHERE faction = '1',resultID) - Threaded query with id 1 started. (Extra ID: 0)

[16:34:57] CMySQLHandler::Ping() - An error has occured (MySQL server has gone away, Error ID: 2006)

[16:34:57] CMySQLHandler::ProcessQueryThread(SELECT * FROM characters WHERE faction = '1', Resultid: 1) - An error has occured in your query. (MySQL server has gone away))

[16:35:00] >> mysql_query( Connection handle: 1 )

[16:35:00] CMySQLHandler::Query(SELECT * FROM characters WHERE faction = '1',resultID) - Threaded query with id 1 started. (Extra ID: 0)

[16:35:00] CMySQLHandler::Ping() - An error has occured (MySQL server has gone away, Error ID: 2006)

[16:35:00] CMySQLHandler::ProcessQueryThread(SELECT * FROM characters WHERE faction = '1', Resultid: 1) - An error has occured in your query. (MySQL server has gone away))
What's wrong?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)