SA-MP Forums Archive
Removal of un-threaded queries created a problem. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Removal of un-threaded queries created a problem. (/showthread.php?tid=484860)



Removal of un-threaded queries created a problem. - GiamPy. - 01.01.2014

The complete removal of un-threaded queries in BlueG's MySQL plugin has created an issue.

It is not anymore possible (as far as I know) returning from a function the result of a query because it's retrieved in another callback and not in the called function. By that I mean, for example:

Pseudocode:
pawn Код:
stock getDBID("Name")
{
    sql_query("query the name");
    databaseid = retrieve_database_id;
    return databaseid;
}
Now, you can't do such thing. You must do something like:

Pseudocode:
pawn Код:
stock getDBID("Name")
{
    sql_query("query the name");
    retrieve_database_id("callback_getdb", params);
}

forward callback_getdb(params);
public callback_getdb(params)
{
    databaseid = id_found_from_query;
}
Now, maybe with #emit functions it might be possible, but I might be wrong.

Any idea on how to fix this?


Re: Removal of un-threaded queries created a problem. - Scenario - 01.01.2014

As far as I know, BlueG's plugin still has y_inline capability. You could always use that to get the return information from the database within the same callback/function you're working in.

Example:

pawn Код:
inline QueryCallback()
{
    new
        rows,
        fields;
       
    cache_get_data(rows, fields);
       
    if(rows > 0)
    {
        new
            szTempString[30],
            authType;
       
        cache_get_row(0, 2, szTempString), authType = strval(szTempString);
        cache_get_row(0, 3, szTempString);
    }
   
        new
            szQuery[75];
   
        format(szQuery, sizeof(szQuery), "SELECT * FROM `radioFrequencies` WHERE `frequency` = '%s'", szSecOption);
        mysql_tquery_inline(dbHandle, szQuery, using inline QueryCallback, "");
    }
}
EDIT: I believe he re-added non-threaded queries, too.


Re: Removal of un-threaded queries created a problem. - Kar - 01.01.2014

unthreaded queries?

mysql_query?

Have you read the last few mysql update changes?


Re: Removal of un-threaded queries created a problem. - GiamPy. - 01.01.2014

Quote:
Originally Posted by Kar
Посмотреть сообщение
unthreaded queries?

mysql_query?

Have you read the last few mysql update changes?
What updates?


Re: Removal of un-threaded queries created a problem. - Scenario - 01.01.2014

That change was listed on the ****** Code page before the project was moved to GitHub. Check out the Wiki for it, though!

https://sampwiki.blast.hk/wiki/MySQL/R33#mysql_query


Re: Removal of un-threaded queries created a problem. - GiamPy. - 01.01.2014

Well, I did not know that.

Thank you.