[Tutorial] Using BlueG's MySQL plugin R7 (with cache)
#50

Quote:
Originally Posted by scott1
Посмотреть сообщение
Thank you for the time that you spend for us,
i got an another question is it possible to not call and callback with the mysql func query?

like this

Код:
new query[768];
    format(query, sizeof(query), "SELECT * FROM `"db_players"` WHERE ID = %d LIMIT 1", id);
 	mysql_function_query(MySQL_Handle, query, false,"","");
	mysql_store_result(MySQL_Handle);
	new resultat = mysql_num_rows(MySQL_Handle);
	mysql_free_result(MySQL_Handle);
	if(resultat >= 1) { return 1; }
	return 0;
Max
Hey.

This code has to follow the examples I set in the post above yours, as well. There are no exceptions to this.

Quote:
Originally Posted by Gumica
Посмотреть сообщение
Is this correct usage of new query:

pawn Код:
mysql_function_query(dbHandle,"UPDATE playerdata SET score= %d, money= %d WHERE user=%s",false,"","dds", score, money, pname)
No. mysql_function_query does not behave as format or mysql_format functions. Since I have been experiencing issues with the mysql_format function, I've reverted to using regular format. Like this:
pawn Код:
format(query, sizeof(query), "UPDATE playerdata SET score=%d,money=%d WHERE user='%s'", score, money, pname);
mysql_function_query(dbHandle, query, false, "", "");
Note that usually player names do not need to be escaped since they cannot contain harmful characters at all. However if your server does a SetPlayerName depending on the user input, it would be good if you added extra checks prior to SetPlayerName to ensure that only the characters allowed to connect with are being used.
Additionally, since you're not going to fire a callback once the query finishes, there's no need to pass the score, money and pname parameters to an nonexistent callback.

Quote:
Originally Posted by costel_nistor96
Посмотреть сообщение
Thanks. (Already repped you when you replied me, but I didn't made a post)

Now I have 3 new questions:
1. Cache can be used in every thread, if no, when it's bad to use it ?
2. Which one is faster, sscanf, or cache_get_row ?
3. Why you use "LIMIT" in this:
Код:
mysql_function_query(dbHandle, "SELECT kills,deaths,level FROM players WHERE name = 'MP2' LIMIT 0,1", true, "OnPlayerDataLoad", "i", playerid);
? What it actually does ? I thought it's good only on ordering ("ORDER BY").
Thank you, and:
1. Cache functions can be used in every thread, yes. I suppose that the benefit from the cache functions is negligible in many cases and I have not ran any speed tests with queries that only receive, lets say, 1-2 fields of data.
2. However I'll combine the answer to the second question with the first one a bit: you need to think through what the plugin does in the first place. When you use cache, it stores the data to a vector as soon as the query is finished. This means that later on, the MySQL result does not have to be accessed, only the vector. About the parsing: you cannot use sscanf with caching, because it does not output a raw string with all fields. I have found sscanf to be quite quite fast in the past though, and I might be wrong, but I think when parsing about 20 fields, the cache_get_row and sscanf parsing were almost the same in speed. Or if slower, then the benefit of not having to use mysql_fetch_row makes up for all the lost microseconds!
3. I am not sure whether that code is from the original post or not, but it would be smart to specify a LIMIT clause when you're expecting that the query could return multiple rows. This will just speed up the behavior a bit since only one row will be returned to the plugin by the MySQL server. However if the name is a PRIMARY KEY, this should not be an issue (that'll allow only one such name to be present). Also I'd suggest everyone to use a system of unique keys for registered player. This will also make using multiple tables a lot easier.

Quote:
Originally Posted by TheArcher
Посмотреть сообщение
Any basic tutorial about how to create a saving system? :/
Sorry, I have been real busy with personal stuff and taking a vacation from my job in the past few weeks. I know that you and few others have requested for a tutorial on a saving/account system. I am going to make one, yes, but it needs some more thinking to be done.

Sorry for the late reply, and thanks for using the tutorial!
Reply


Messages In This Thread
Using BlueG's MySQL plugin R7 and newer (with cache) - by AndreT - 27.04.2012, 22:55
Re: Using BlueG's MySQL plugin R7 (with cache) - by Ricop522 - 28.04.2012, 05:01
Re: Using BlueG's MySQL plugin R7 (with cache) - by Niko_boy - 28.04.2012, 05:04
Respuesta: Using BlueG's MySQL plugin R7 (with cache) - by [Vector] - 28.04.2012, 05:36
Re: Using BlueG's MySQL plugin R7 (with cache) - by Burridge - 28.04.2012, 08:31
Re: Respuesta: Using BlueG's MySQL plugin R7 (with cache) - by AndreT - 28.04.2012, 08:51
Re: Using BlueG's MySQL plugin R7 (with cache) - by Lorenc_ - 28.04.2012, 09:39
Respuesta: Using BlueG's MySQL plugin R7 (with cache) - by [Vector] - 30.04.2012, 19:20
Re: Using BlueG's MySQL plugin R7 (with cache) - by AndreT - 30.04.2012, 20:03
Re: Using BlueG's MySQL plugin R7 (with cache) - by MP2 - 18.05.2012, 16:50
Re: Using BlueG's MySQL plugin R7 (with cache) - by kikito - 18.05.2012, 16:51
Re: Using BlueG's MySQL plugin R7 (with cache) - by AndreT - 18.05.2012, 19:29
Re: Using BlueG's MySQL plugin R7 (with cache) - by MP2 - 18.05.2012, 19:44
Re: Using BlueG's MySQL plugin R7 (with cache) - by AndreT - 18.05.2012, 19:51
Re: Using BlueG's MySQL plugin R7 (with cache) - by MP2 - 18.05.2012, 20:03
Re: Using BlueG's MySQL plugin R7 (with cache) - by AndreT - 18.05.2012, 20:37
Re: Using BlueG's MySQL plugin R7 (with cache) - by MP2 - 18.05.2012, 21:42
Re: Using BlueG's MySQL plugin R7 (with cache) - by AndreT - 19.05.2012, 08:18
Re: Using BlueG's MySQL plugin R7 (with cache) - by MP2 - 19.05.2012, 12:04
Re: Using BlueG's MySQL plugin R7 (with cache) - by Hiddos - 19.05.2012, 12:07
Re: Using BlueG's MySQL plugin R7 (with cache) - by Luis- - 20.05.2012, 00:29
Re : Using BlueG's MySQL plugin R7 (with cache) - by Vukilore - 21.05.2012, 16:28
Respuesta: Using BlueG's MySQL plugin R7 (with cache) - by Sauxe - 22.05.2012, 03:26
Re: Using BlueG's MySQL plugin R7 (with cache) - by TheArcher - 23.05.2012, 19:06
Re: Using BlueG's MySQL plugin R7 (with cache) - by AShop - 27.05.2012, 18:08
Re: Using BlueG's MySQL plugin R7 (with cache) - by Luis- - 27.05.2012, 18:19
Re: Using BlueG's MySQL plugin R7 (with cache) - by AndreT - 27.05.2012, 19:16
Re: Using BlueG's MySQL plugin R7 (with cache) - by ArchBishop - 27.05.2012, 20:25
Re: Using BlueG's MySQL plugin R7 (with cache) - by AndreT - 27.05.2012, 20:43
Re: Using BlueG's MySQL plugin R7 (with cache) - by ArchBishop - 28.05.2012, 20:21
AW: Re: Using BlueG's MySQL plugin R7 (with cache) - by Extremo - 11.06.2012, 07:01
Re: Using BlueG's MySQL plugin R7 (with cache) - by AndreT - 11.06.2012, 10:08
Re: Using BlueG's MySQL plugin R7 (with cache) - by Kyle - 11.06.2012, 11:08
Re: Using BlueG's MySQL plugin R7 (with cache) - by AndreT - 11.06.2012, 11:56
AW: Using BlueG's MySQL plugin R7 (with cache) - by Extremo - 11.06.2012, 12:18
Re: Using BlueG's MySQL plugin R7 (with cache) - by MP2 - 23.06.2012, 09:23
Re: Using BlueG's MySQL plugin R7 (with cache) - by Kyle - 23.06.2012, 10:13
Re: Using BlueG's MySQL plugin R7 (with cache) - by MP2 - 23.06.2012, 13:37
Re: Using BlueG's MySQL plugin R7 (with cache) - by Kyle - 23.06.2012, 13:40
AW: Using BlueG's MySQL plugin R7 (with cache) - by Cank - 23.06.2012, 14:02
Re: Using BlueG's MySQL plugin R7 (with cache) - by AndreT - 23.06.2012, 14:34
Re: Using BlueG's MySQL plugin R7 (with cache) - by SWEMike - 30.06.2012, 12:37
Re: Using BlueG's MySQL plugin R7 (with cache) - by AndreT - 30.06.2012, 20:21
Re: Using BlueG's MySQL plugin R7 (with cache) - by Splav - 02.07.2012, 13:10
Re: Using BlueG's MySQL plugin R7 (with cache) - by Coicatak - 10.07.2012, 12:08
Re : Using BlueG's MySQL plugin R7 (with cache) - by scott1 - 16.07.2012, 17:39
Re: Using BlueG's MySQL plugin R7 (with cache) - by AndreT - 17.07.2012, 20:28
Re : Using BlueG's MySQL plugin R7 (with cache) - by scott1 - 18.07.2012, 11:34
Re: Using BlueG's MySQL plugin R7 (with cache) - by Gumica - 22.07.2012, 12:35
Re: Re : Using BlueG's MySQL plugin R7 (with cache) - by AndreT - 27.07.2012, 10:19
Re: Using BlueG's MySQL plugin R7 (with cache) - by AndreT - 29.09.2012, 22:53
Re: Using BlueG's MySQL plugin R7 (with cache) - by Richie© - 03.10.2012, 21:08
Re: Using BlueG's MySQL plugin R7 (with cache) - by ReneG - 04.10.2012, 05:00
Re: Using BlueG's MySQL plugin R7 (with cache) - by Richie© - 04.10.2012, 20:54
Re: Using BlueG's MySQL plugin R7 (with cache) - by ScriptWriter - 12.10.2012, 15:56
Re: Using BlueG's MySQL plugin R7 (with cache) - by AndreT - 13.10.2012, 12:58
Re: Using BlueG's MySQL plugin R7 (with cache) - by ScriptWriter - 13.10.2012, 13:03
Re: Using BlueG's MySQL plugin R7 (with cache) - by AndreT - 13.10.2012, 13:05
Re: Using BlueG's MySQL plugin R7 (with cache) - by ScriptWriter - 13.10.2012, 13:15
Re: Using BlueG's MySQL plugin R7 (with cache) - by AndreT - 13.10.2012, 14:33
Re: Using BlueG's MySQL plugin R7 (with cache) - by ScriptWriter - 13.10.2012, 14:54
Re: Using BlueG's MySQL plugin R7 (with cache) - by AndreT - 13.10.2012, 15:04
Re: Using BlueG's MySQL plugin R7 (with cache) - by ScriptWriter - 01.11.2012, 07:58
Re: Using BlueG's MySQL plugin R7 (with cache) - by Edvin - 01.11.2012, 08:01
Re: Using BlueG's MySQL plugin R7 (with cache) - by ScriptWriter - 01.11.2012, 08:20
Re: Using BlueG's MySQL plugin R7 (with cache) - by IstuntmanI - 01.11.2012, 12:52
Re: Using BlueG's MySQL plugin R7 (with cache) - by ScriptWriter - 01.11.2012, 14:06
Re: Using BlueG's MySQL plugin R7 (with cache) - by IstuntmanI - 01.11.2012, 14:13
Re: Using BlueG's MySQL plugin R7 (with cache) - by ScriptWriter - 01.11.2012, 15:00
Re: Using BlueG's MySQL plugin R7 (with cache) - by ReneG - 01.11.2012, 16:09
Re: Using BlueG's MySQL plugin R7 (with cache) - by ReneG - 11.11.2012, 19:25
Re: Using BlueG's MySQL plugin R7 (with cache) - by AirKite - 11.11.2012, 20:05
Re: Using BlueG's MySQL plugin R7 (with cache) - by fordawinzz - 23.11.2012, 12:33
Re: Using BlueG's MySQL plugin R7 (with cache) - by AndreT - 23.11.2012, 13:50
Re: Using BlueG's MySQL plugin R7 (with cache) - by fordawinzz - 24.11.2012, 09:38
Re: Using BlueG's MySQL plugin R7 (with cache) - by AndreT - 24.11.2012, 11:20
Re: Using BlueG's MySQL plugin R7 (with cache) - by EterNo - 26.11.2012, 12:54
Re: Using BlueG's MySQL plugin R7 (with cache) - by EterNo - 26.11.2012, 18:28
Re: Using BlueG's MySQL plugin R7 (with cache) - by CoDeZ - 26.11.2012, 21:30
Re: Using BlueG's MySQL plugin R7 (with cache) - by Marusa - 03.12.2012, 18:26
Re: Using BlueG's MySQL plugin R7 (with cache) - by DaLgakıran - 30.05.2013, 14:01
Re: Using BlueG's MySQL plugin R7 (with cache) - by AndreT - 09.06.2013, 10:28
Re: Using BlueG's MySQL plugin R7 (with cache) - by Yashas - 21.07.2013, 08:56
Re: Using BlueG's MySQL plugin R7 (with cache) - by Richie© - 21.07.2013, 09:07
Re: Using BlueG's MySQL plugin R7 (with cache) - by Yashas - 21.07.2013, 09:21
Re: Using BlueG's MySQL plugin R7 (with cache) - by Richie© - 21.07.2013, 10:52
Re: Using BlueG's MySQL plugin R7 (with cache) - by Misiur - 21.07.2013, 10:57
Re: Using BlueG's MySQL plugin R7 (with cache) - by IstuntmanI - 21.07.2013, 11:14
Re: Using BlueG's MySQL plugin R7 (with cache) - by Grumbles - 28.07.2013, 23:46
Re: Using BlueG's MySQL plugin R7 (with cache) - by Luis- - 29.07.2013, 03:28
Re: Using BlueG's MySQL plugin R7 (with cache) - by Grumbles - 29.07.2013, 15:22
Re: Using BlueG's MySQL plugin R7 (with cache) - by Yashas - 30.07.2013, 03:07
Re: Using BlueG's MySQL plugin R7 (with cache) - by Michalec - 29.10.2013, 14:43
Re: Using BlueG's MySQL plugin R7 (with cache) - by gotwarzone - 12.11.2013, 08:50
Re : Using BlueG's MySQL plugin R7 (with cache) - by ombre - 11.01.2014, 13:35
Re: Using BlueG's MySQL plugin R7 (with cache) - by anou1 - 13.01.2014, 16:52
Re: Using BlueG's MySQL plugin R7 (with cache) - by dusk - 14.01.2014, 13:25
Re: Using BlueG's MySQL plugin R7 (with cache) - by KevinPRINCE - 22.02.2014, 20:51
Re: Using BlueG's MySQL plugin R7 (with cache) - by Guest4390857394857 - 20.03.2014, 08:03
Re: Using BlueG's MySQL plugin R7 (with cache) - by AiRaLoKa - 16.05.2014, 13:03
Re: Using BlueG's MySQL plugin R7 (with cache) - by ~Yoshi - 05.09.2015, 00:50
Re: Using BlueG's MySQL plugin R7 (with cache) - by AmigaBlizzard - 27.01.2016, 23:27
Re: Using BlueG's MySQL plugin R7 (with cache) - by maddinat0r - 29.01.2016, 13:07
Re: Using BlueG's MySQL plugin R7 (with cache) - by AmigaBlizzard - 07.02.2016, 12:05
Re: Using BlueG's MySQL plugin R7 (with cache) - by maddinat0r - 07.02.2016, 14:38
Re: Using BlueG's MySQL plugin R7 (with cache) - by AmigaBlizzard - 10.02.2016, 20:42
Re: Using BlueG's MySQL plugin R7 (with cache) - by Slawiii - 11.05.2016, 18:26
Re: Using BlueG's MySQL plugin R7 (with cache) - by thesuperuser - 13.05.2016, 12:36
Re: Using BlueG's MySQL plugin R7 (with cache) - by iSpy - 13.05.2016, 12:38

Forum Jump:


Users browsing this thread: 1 Guest(s)