[Tutorial] How to make a MySQL Admin System!
#22

Quote:
Originally Posted by VincentDunn
View Post
I would recommend separate callbacks, but it really is just personal preference.

For example with one callback
pawn Code:
#define RESULT_LOAD (1)
#define RESULT_SAVE (2)

public OnQueryExecute(resultid, playerid)
{
    new rows, fields;
    cache_get_data(rows, fields);

    switch (resultid) {
        case RESULT_LOAD:
            // code here
        case RESULT_SAVE:
            // code here
    }

    return 1;
}
This can get pretty hard to work with the more queries you script in, but it gets the job done. You can argue that the switch statement will slow it down, but the difference would practically be zero.

with single callbacks
pawn Code:
LoadPlayer(playerid)
{
    // code here
}

public OnPlayerLoad(playerid)
{
    new rows, fields;
    cache_get_data(rows, fields);

    // code here
    return 1;
}
 
SavePlayer(playerid)
{
    // code here
}

public OnPlayerSave(playerid)
{
    printf("Player %d saved.", playerid);
    return 1;
}
It may seem like a lot more lines, but it's a lot easier to handle this way IMO. You don't have to deal with different result ids, there are less mistakes to be made, and you can safely say that your query will only execute what you put into its according callback.

tl;dr - it doesn't really matter, as long as you take efficient advantage of the plugin, then you're fine
Yeah that's what I thought. I found it more systematic with separate callbacks, so that's what I'll hold on to.
Reply


Messages In This Thread
How to make a MySQL Admin System! - by kamzaf - 13.03.2013, 02:07
Re: How to make a MySQL Admin System! - by RajatPawar - 13.03.2013, 05:42
Re: How to make a MySQL Admin System! - by Vince - 13.03.2013, 06:09
Re: How to make a MySQL Admin System! - by kamzaf - 13.03.2013, 14:34
Respuesta: How to make a MySQL Admin System! - by MiGu3X - 13.03.2013, 15:25
Re: How to make a MySQL Admin System! - by RajatPawar - 13.03.2013, 15:54
Re: How to make a MySQL Admin System! - by Bakr - 13.03.2013, 16:10
Re: How to make a MySQL Admin System! - by daddyblake - 13.03.2013, 17:22
Re: How to make a MySQL Admin System! - by kamzaf - 14.03.2013, 18:52
Re: How to make a MySQL Admin System! - by M0nSt3r - 20.03.2013, 22:14
Re: How to make a MySQL Admin System! - by Scenario - 20.03.2013, 22:21
Re: How to make a MySQL Admin System! - by kamzaf - 20.03.2013, 23:18
Re: How to make a MySQL Admin System! - by Scenario - 20.03.2013, 23:53
Respuesta: How to make a MySQL Admin System! - by PabloDiCostanzo - 21.03.2013, 01:17
Re : Respuesta: How to make a MySQL Admin System! - by kamzaf - 21.03.2013, 02:30
Respuesta: How to make a MySQL Admin System! - by PabloDiCostanzo - 21.03.2013, 19:37
Re: How to make a MySQL Admin System! - by ReneG - 21.03.2013, 20:02
Re: How to make a MySQL Admin System! - by LarzI - 21.03.2013, 20:14
Re: How to make a MySQL Admin System! - by ReneG - 21.03.2013, 21:12
Re: How to make a MySQL Admin System! - by Konstantinos - 21.03.2013, 21:26
Re: How to make a MySQL Admin System! - by ReneG - 21.03.2013, 21:35
Re: How to make a MySQL Admin System! - by LarzI - 22.03.2013, 07:01
Re: Respuesta: How to make a MySQL Admin System! - by kamzaf - 25.03.2013, 21:26
Re: How to make a MySQL Admin System! - by Trooja - 29.03.2013, 20:48
Re: How to make a MySQL Admin System! - by kamzaf - 30.03.2013, 01:14
Re: How to make a MySQL Admin System! - by Trooja - 30.03.2013, 13:28
Re: How to make a MySQL Admin System! - by kamzaf - 30.03.2013, 17:14
Re: How to make a MySQL Admin System! - by Trooja - 30.03.2013, 20:58
Re: How to make a MySQL Admin System! - by Trooja - 01.04.2013, 13:14
Re: How to make a MySQL Admin System! - by kamzaf - 13.04.2013, 17:01
Re: How to make a MySQL Admin System! - by YanLanger - 29.09.2014, 13:31
Re: How to make a MySQL Admin System! - by vignesh007 - 29.09.2014, 14:13
Re: How to make a MySQL Admin System! - by Ryz - 05.10.2014, 05:06
Re: How to make a MySQL Admin System! - by Ryz - 22.10.2014, 12:51
Re: How to make a MySQL Admin System! - by Hittop65 - 30.11.2014, 01:56
Re: How to make a MySQL Admin System! - by DemME - 30.11.2014, 02:50

Forum Jump:


Users browsing this thread: 5 Guest(s)