help with basic mysql
#6

If you want to keep your logic coupled, I recommend using y_inline from YSI:
pawn Код:
#include <YSI\y_va>
#include <YSI\y_inline>
#include <a_mysql>

//(...)

public OnPlayerConnect(playerid)
{
    new
        query[64]
    ;
    mysql_format(dbHandle, sizeof(query), "SELECT job FROM `players` WHERE `userid` = %d", hereID);

    inline YourHandle() {
        new
            rows = cache_get_row_count(dbHandle)
        ;
        //Playerid is still available here!
        if (!rows) {
            va_SendClientMessage(playerid, 0xBADA55AA, "Sorry, there is not a single job for player %d", hereID);
            return;
        }

        new
            jobID
        ;
        for (new row = 0; row != rows; ++i) {
            jobID = cache_get_field_content_int(0, "job", dbHandle);
       
            printf("Fetched job %d", jobID);
        }
    }

    mysql_tquery_inline(dbHandle, query, using inline Yourhandle, "");

    //Watch out, outside that inline you can't be sure that the query was already finished
}
Reply


Messages In This Thread
help with basic mysql - by Veng3eur - 10.03.2015, 19:27
Re: help with basic mysql - by Veng3eur - 11.03.2015, 14:03
AW: help with basic mysql - by Kaliber - 11.03.2015, 14:04
Re: help with basic mysql - by Veng3eur - 11.03.2015, 14:07
AW: help with basic mysql - by Kaliber - 11.03.2015, 14:15
Re: help with basic mysql - by Misiur - 11.03.2015, 14:41
Re: help with basic mysql - by Veng3eur - 11.03.2015, 14:47

Forum Jump:


Users browsing this thread: 1 Guest(s)