Returning data using threaded queries?
#1

Alright so I've been thinking about this, is it even possible to retrieve data from the Tqueries directly from the command itself? For example


(example code)
pawn Код:
CMD:test(playerid,params[]) {
    new query[128];
    mysql_format(mysql,query,sizeof(query),"SELECT * FROM sometable");
    mysql_tquery(mysql,query,"onSomeResponse","i",playerid);
   
    //How to get onSomeResponse return here?
    return true;
}

public onSomeResponse(playerid) {
    if(rows bla bla bla) {
        return true;
    }
    return false;
}

I've tried YSI inline but couldnt really do much with it, response would still be un-accessiable.
Reply
#2

No, you can't. But you can still do that by using mysql_query().
Example:
Код:
CMD:test(playerid,params[]) {
	new query[128], Cache:qcache;
	mysql_format(mysql,query,sizeof(query),"SELECT * FROM sometable");
	qcache = mysql_query(mysql, query, true); // Remember to save the cache into a variable so you can delete this later to free up your memory
	// ... cache_ stuff here
	cache_delete(qcache);	
	return true;
}
Inline example: (You need y_inline from YSI to use tquery_inline)
Код:
CMD:test(playerid,params[]) {
    new query[128];

    inline InlineCallback(bla)
    {
        // ... cache_ stuff here
    }

    mysql_format(mysql,query,sizeof(query),"SELECT * FROM sometable");
    mysql_tquery_inline(mysql, query, using inline InlineCallback, "d", playerid);
    return true;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)