SA-MP Forums Archive
[Include] PVar database - The easiest way for a user database - SQLITE, MYSQL - 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: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] PVar database - The easiest way for a user database - SQLITE, MYSQL (/showthread.php?tid=590423)

Pages: 1 2


Re: PVar database - The easiest way for a user database - SQLITE, MYSQL - Crayder - 25.03.2016

Quote:
Originally Posted by Gammix
View Post
What i meant was sort of similar to this logic.
Example:
Code:
SavePVar(playerid, "Test");
// The execute interval has started

// New variables added (query isn't executed)
SavePVar(playerid, "Test2");
SavePVar(playerid, "Test3");
SavePVar(playerid, "Test4");

// After 'X' seconds (say 2 secs), the query is executed and result is free!
(similar with loading functions)
The problem with this is things can go wrong, like what if that player disconnected within those 2 seconds? Or what if the server crashed? Or anything else that causes interruptions.

Giving the users the ability to run transactions would solve this.

Code:
//Single Query
SavePVar(playerid, "Test0");

//Multiple Queries
StartPVarQuery(); // Macro for db_query("BEGIN")
SavePVar(playerid, "Test");
SavePVar(playerid, "Test2");
SavePVar(playerid, "Test3");
SavePVar(playerid, "Test4");
EndPVarQuery(); // Macro for db_query("COMMIT")
Also, transactions are super quick, so this would speed up a lot of things. Transactions can run extreme amounts of queries in a single swoop in a very small amount of time.


Re: PVar database - The easiest way for a user database - SQLITE, MYSQL - Gammix - 25.03.2016

Quote:
Originally Posted by Crayder
View Post
The problem with this is things can go wrong, like what if that player disconnected within those 2 seconds? Or what if the server crashed? Or anything else that causes interruptions.

Giving the users the ability to run transactions would solve this.

Code:
//Single Query
SavePVar(playerid, "Test0");

//Multiple Queries
StartPVarQuery(); // Macro for db_query("BEGIN")
SavePVar(playerid, "Test");
SavePVar(playerid, "Test2");
SavePVar(playerid, "Test3");
SavePVar(playerid, "Test4");
EndPVarQuery(); // Macro for db_query("COMMIT")
Also, transactions are super quick, so this would speed up a lot of things. Transactions can run extreme amounts of queries in a single swoop in a very small amount of time.
Yes that's a very nice way, even that can be an alternative for YouSQL or EasyDB.
But, just few extra lines out of standard :P

Also, this can be resolved easily because player's name can be stored into the timer when the execute timer begins.


Re: PVar database - The easiest way for a user database - SQLITE, MYSQL - MrFantasy - 28.05.2017

Can this still be used with MYSQL R41-2?