SA-MP Forums Archive
[Tutorial] Using BlueG's MySQL plugin R7 (with cache) - 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)
+---- Forum: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] Using BlueG's MySQL plugin R7 (with cache) (/showthread.php?tid=337810)

Pages: 1 2 3 4 5 6


Re: Using BlueG's MySQL plugin R7 (with cache) - DaLgakıran - 30.05.2013

https://code.******.com/p/sa-mp-mysq...s/detail?id=25

Can someone help me with this?


Re: Using BlueG's MySQL plugin R7 (with cache) - AndreT - 09.06.2013

Hm - I've worked with similar grouping before. I think you should wrap up t1.time in MIN().

// Edit. Did not see you had solved it. However if you see this, feel free to post your solution to it. I remember such queries making me shiver all over a few years ago.


Re: Using BlueG's MySQL plugin R7 (with cache) - Yashas - 21.07.2013

Is is compulsory to give a function to function_query??

Can I do it like

Code:
CheckAccountExists(account[])
{
	new string[128];
	format(string, sizeof(string), "SELECT * FROM player_accounts WHERE Name = '%s'", account);
	mysql_function_query(dbHandle,string,FALSE, "", "");

	new value;
	value = mysql_num_rows();
	return value;
}



Re: Using BlueG's MySQL plugin R7 (with cache) - Richie© - 21.07.2013

Yes, it is in R7 or later.


Re: Using BlueG's MySQL plugin R7 (with cache) - Yashas - 21.07.2013

But it doesn't work for me


Re: Using BlueG's MySQL plugin R7 (with cache) - Richie© - 21.07.2013

You can do it this way;
pawn Code:
CheckAccountExists(account[])
{
    new string[128];
    format(string, sizeof(string), "SELECT * FROM player_accounts WHERE Name = '%s'", account);
    mysql_function_query(dbHandle, string, true, "CheckAccount", "s", account);
}

forward CheckAccount(account[]);
public CheckAccount(account[])
{
    new rows, fields;
    cache_get_data(rows, fields);
   
    if(!rows)
    {
        // account does not exist, register?
    }
    else
    {
        //proceed to login?
    }
    return 1; // To clear cache
}
If you want to do it the 'old' way, without CheckAccount callback, you can try y_inline which is supported in R31.


Re: Using BlueG's MySQL plugin R7 (with cache) - Misiur - 21.07.2013

Guys, I updated from R15 to R27 few days ago and now we have R31? Are those all bugfixes, or are there some new features? What's the status of mysql_format and linux (I'm using it extensively with %e instead of normal format + mysql_real_escape_string)? Is there some compact changelog (I'm not so comfortable in using ****** code instead of github), other than fixed issues list?

#e: 1k post, yay


Re: Using BlueG's MySQL plugin R7 (with cache) - IstuntmanI - 21.07.2013

Quote:
Originally Posted by Misiur
View Post
Guys, I updated from R15 to R27 few days ago and now we have R31? Are those all bugfixes, or are there some new features? What's the status of mysql_format and linux (I'm using it extensively with %e instead of normal format + mysql_real_escape_string)? Is there some compact changelog (I'm not so comfortable in using ****** code instead of github), other than fixed issues list?

#e: 1k post, yay
I think you can use mysql_format without crashes now, I didn't tested it. Give it a try !

https://code.******.com/p/sa-mp-mysq...ce/detail?r=28
https://code.******.com/p/sa-mp-mysq...ce/detail?r=29
https://code.******.com/p/sa-mp-mysq...ce/detail?r=30
https://code.******.com/p/sa-mp-mysq...ce/detail?r=31

Quote:

- added '%%' specifier to native 'mysql_format'

- mysql_reconnect returns true if connection is established, else false

- added optional parameter "autoreconnect" to mysql_connect to control whether
the plugin should reconnect automatically if connection is lost

- added optional parameter "wait" to mysql_close to control whether the plugin
should wait till all pending queries are executed or not

- re-added our old and beloved native mysql_errno

Those are all things changed from R27-R28, the rest are improvements and fixes.


Re: Using BlueG's MySQL plugin R7 (with cache) - Grumbles - 28.07.2013

Code:
forward AracYukle();
public AracYukle()
{
	new resultline[1024];
	new car[37][64];
	new query[100];
	mysql_real_escape_string("SELECT * FROM araclar ORDER BY id ASC",query);
	mysql_query(query);
	mysql_store_result();
    for(new h = 0; h < sizeof(DynamicCars); h++)
	{
		while(mysql_fetch_row(resultline)==1)
		{
			H_split(resultline, car, '|');
			h = AddStaticVehicleEx(strval(car[1]), floatstr(car[2]), floatstr(car[3]), floatstr(car[4]), floatstr(car[5]), strval(car[6]), strval(car[7]), -1);
			DynamicCars[h][cSQLid] = strval(car[0]);
			DynamicCars[h][CarModel] = strval(car[1]);
			DynamicCars[h][CarX] = floatstr(car[2]);
			DynamicCars[h][CarY] = floatstr(car[3]);
			DynamicCars[h][CarZ] = floatstr(car[4]);
			DynamicCars[h][CarAngle] = floatstr(car[5]);
			DynamicCars[h][CarColor1] = strval(car[6]);
			DynamicCars[h][CarColor2] = strval(car[7]);
			DynamicCars[h][FactionCar] = strval(car[8]);
			DynamicCars[h][CarType] = strval(car[9]);
			DynamicCars[h][CarValue] = strval(car[10]);
			DynamicCars[h][CarOwned] = strval(car[11]);
	        strmid(DynamicCars[h][CarOwner], car[12], 0, strlen(car[12]), 20);
	        strmid(DynamicCars[h][CarDescription],car[13], 0, strlen(car[13]), 20);
			DynamicCars[h][CarHealth] = floatstr(car[14]);
			DynamicCars[h][AracPatladi] = strval(car[15]);
			DynamicCars[h][AracKiraZaman] = strval(car[16]);
			DynamicCars[h][cSigorta] = strval(car[17]);
			DynamicCars[h][cKazaSayi] = strval(car[18]);
			DynamicCars[h][ModPaintjob] = strval(car[19]);
			DynamicCars[h][ModSpoiler] = strval(car[20]);
			DynamicCars[h][ModRoof] = strval(car[21]);
			DynamicCars[h][ModLeftSideSkirt] = strval(car[22]);
			DynamicCars[h][ModRightSideSkirt] = strval(car[23]);
			DynamicCars[h][ModExhaust] = strval(car[24]);
			DynamicCars[h][ModWheels] = strval(car[25]);
			DynamicCars[h][ModFrontBumper] = strval(car[26]);
			DynamicCars[h][ModRearBumper] = strval(car[27]);
			DynamicCars[h][ModStereo] = strval(car[28]);
			DynamicCars[h][ModHydraulics] = strval(car[29]);
			DynamicCars[h][ModNitro] = strval(car[30]);
			DynamicCars[h][ModNeon] = strval(car[31]);
			DynamicCars[h][ModAlarm] = strval(car[32]);
			DynamicCars[h][Panels] = strval(car[33]);
			DynamicCars[h][Doors] = strval(car[34]);
			DynamicCars[h][Lights] = strval(car[35]);
			DynamicCars[h][Tires] = strval(car[36]);
			AraciModifiyeEt(h);
			h++;
		}
	}
}
Can you give me to change it in the form of MySQL R7(BlueG's)?


Re: Using BlueG's MySQL plugin R7 (with cache) - Luis- - 29.07.2013

Have you tried to do it yourself? It's a big code and you should really be trying to convert it yourself.


Re: Using BlueG's MySQL plugin R7 (with cache) - Grumbles - 29.07.2013

I'm working on it for a week and I could not, really.


Re: Using BlueG's MySQL plugin R7 (with cache) - Yashas - 30.07.2013

Quote:
Originally Posted by Richie©
View Post
You can do it this way;
pawn Code:
CheckAccountExists(account[])
{
    new string[128];
    format(string, sizeof(string), "SELECT * FROM player_accounts WHERE Name = '%s'", account);
    mysql_function_query(dbHandle, string, true, "CheckAccount", "s", account);
}

forward CheckAccount(account[]);
public CheckAccount(account[])
{
    new rows, fields;
    cache_get_data(rows, fields);
   
    if(!rows)
    {
        // account does not exist, register?
    }
    else
    {
        //proceed to login?
    }
    return 1; // To clear cache
}
If you want to do it the 'old' way, without CheckAccount callback, you can try y_inline which is supported in R31.
The problem I have are:
*First of all, I am updating from R5 to R7
*I have used if(CheckAccountExists(...))

How do make change to the code without effecting these ifs??
Thanks


Re: Using BlueG's MySQL plugin R7 (with cache) - Michalec - 29.10.2013

I have question: how to make function like GetPlayerInt(playerid, field[]) using cache? I don't want to create functions to all my queries.


Re: Using BlueG's MySQL plugin R7 (with cache) - gotwarzone - 12.11.2013

It gives me argument type mismatch (argument 1)

At line mysql_funtion_query

How to solve this?


HTML Code:
new
    count = 10,
    result[2][32], 
    string[(24 + 10) * 10];

mysql_function_query("SELECT `Score`, `PlayerName` FROM `"#MYSQL_TABLE"` ORDER BY `Score` ASC LIMIT 10");
mysql_store_result();

if (mysql_num_rows() < 1) return 0;

while (mysql_retrieve_row() && count > 0)
{
    mysql_fetch_field_row(result[0], "Score");
    mysql_fetch_field_row(result[1], "PlayerName");

    format(string, sizeof(string), "%s%d. %s: %d\n", string, count--, result[1], strval(result[0]));
}
ShowPlayerDialog(playerid, 0, DIALOG_STYLE_MSGBOX, "Top 10", string, "Close", "");



Re : Using BlueG's MySQL plugin R7 (with cache) - ombre - 11.01.2014

I'm lost. My script is for the r6 version. So now r33 r34... is for wich update?


Re: Using BlueG's MySQL plugin R7 (with cache) - anou1 - 13.01.2014

Hi,

How can I use "cache_get_row_int(0, 1);" with the R7 please ? Cause it was fine with R35 but now I got a lot of errors.


Re: Using BlueG's MySQL plugin R7 (with cache) - dusk - 14.01.2014

Quote:
Originally Posted by anou1
View Post
Hi,

How can I use "cache_get_row_int(0, 1);" with the R7 please ? Cause it was fine with R35 but now I got a lot of errors.
You can't, cache_get_row_int and cache_get_row_float were added in R8.

So why don't you just use R35?


Re: Using BlueG's MySQL plugin R7 (with cache) - KevinPRINCE - 22.02.2014

Code:
Plugin version R8 and newer
BlueG has decided to use a public repository for the development of this plugin. This means that others can commit code as well, and some already have. Here are some of the changes:
* Added cache_get_row_int and cache_get_row_float (supported briefly in this tutorial, but I'll continue it some time).
* More security added to internal string handling to prevent buffer overflows.
* Fixed crash issue on gamemode restart (gmx).
* A few more internal issues cleared up.
Lol now my server(linux VPS) doesn't even start, and in the hosted slots the server still keeps restarting

Code:
[17:33:18] [MySQL] (Main Pipelines) Connecting to 5.231.45.5...
[17:33:18] [MySQL] (MainPipeline) Connection successful toward MySQL Database Server!
[17:33:18] [LoadHouses] Loading data from database...
[17:33:18] [LoadDynamicDoors] Loading data from database...
[17:33:18] [LoadDynamicMapIcons] Loading data from database...
[17:33:18] [LoadDynamicTexts] Loading data from database...
[17:33:19] [LoadTurfWars] 40 turfs loaded.
[17:33:19] [LoadPaintballArenas] 10 paintball arenas loaded.
[17:33:19] [LoadEventPoints] 0 event points loaded.
[17:33:19] [LoadGates] 4000 gates loaded.
[17:33:19] [LoadElevatorStuff] 20 floors loaded.
[17:33:19] [LoadFamilies] 16 families loaded.
[17:33:19] [LoadPoints] 9 points loaded.
[17:33:24] [LoadCDealerships] 15 dealerships loaded.
[17:33:24] [MiscLoad] Misc Loaded
[17:33:24] [Tax] Government Tax/Vault Loaded.
[17:33:36] [LoadCDealerships] 15 dealerships loaded.
[17:33:36] [MiscLoad] Misc Loaded
[17:33:36] [Tax] Government Tax/Vault Loaded.



Re: Using BlueG's MySQL plugin R7 (with cache) - Guest4390857394857 - 20.03.2014

nice


Re: Using BlueG's MySQL plugin R7 (with cache) - AiRaLoKa - 16.05.2014

great!!!
i really need this tutorial!
you're the only one who makes me understand what threaded MySQL is...
+REP