pBlueG / SA-MP-MySQL

MySQL plugin for San Andreas Multiplayer
BSD 3-Clause "New" or "Revised" License
197 stars 78 forks source link

push active caches on a stack instead of overwriting them #175

Open maddinat0r opened 6 years ago

maddinat0r commented 6 years ago

This would save all the hassle of storing a result, executing a query, and restoring the previous result.

mysql_tquery(..., "MyCallback");

public MyCallback()
{
    new Cache:res = cache_save();

    for(new i; i != cache_num_rows(); i++)
    {
        FunctionThatCallsMysqlQuery();
        cache_set_active(res);
    }

    cache_delete(res);
}

FunctionThatCallsMysqlQuery()
{
    new Cache:res = mysql_query(...);

    cache_delete(res);
}

Basically restore the previous active cache after the cache_delete call in FunctionThatCallsMysqlQuery. I have to make sure to not break any existing code though, so gotta think this through.

PatrickGTR commented 6 years ago

Yup!