SA-MP Forums

Go Back   SA-MP Forums > SA-MP Server > Server Support

Reply
 
Thread Tools Display Modes
Old 19/10/2018, 05:25 PM   #1
StRaffael
Little Clucker
 
Join Date: Jan 2016
Posts: 6
Reputation: 0
Default Upgrading BluG's MySQL r33 plugin to R40+

Hello there, I just started to upgrade all my scripts from R33 mysql plugin to R40 version. I read this tutorial but I got no informations about alot of functions that I found in my gamemode like:
mysql_num_rows, mysql_num_rows, mysql_free_result, mysql_fetch_row, mysql_real_escape_string, mysql_store_result, mysql_fetch_row, mysql_retrieve_row, mysql_fetch_field_row functions and soo on.. .

Does anyone know how to mess with them?
StRaffael is offline   Reply With Quote
Old 19/10/2018, 05:40 PM   #2
Calisthenics
Huge Clucker
 
Join Date: May 2018
Posts: 349
Reputation: 52
Default Re: Upgrading BluG's MySQL r33 plugin to R40+

These functions belong to R5 and R6 versions.

mysql_num_rows -> cache_num_rows() macro or cache_get_row_count function
mysql_free_result -> cache_delete but only if you store the cache (non-threaded queries)
mysql_fetch_row -> fetches row from result set and also moves row pointer. We do not split result anymore and use a loop to access each row.
mysql_real_escape_string -> mysql_escape_string or '%e' specifier in mysql_format function
mysql_store_result -> cache_save (only used if you want to access the result after a while and not directly)
mysql_retrieve_row -> moves to the next row, use a loop.
mysql_fetch_field_row -> fetches data by column name, use cache_get_value macro only for string. If the data are integers or floating-point numbers, use cache_get_value_int or cache_get_value_float respectively.

Use threaded queries and take a look at wiki for examples or description of each function: https://wiki.sa-mp.com/wiki/MySQL/R40
Calisthenics is offline   Reply With Quote
Old 19/10/2018, 06:16 PM   #3
StRaffael
Little Clucker
 
Join Date: Jan 2016
Posts: 6
Reputation: 0
Default Re: Upgrading BluG's MySQL r33 plugin to R40+

Code:
public LoadBizz()
{
    new PropertyString[256];
	bussines = cache_num_rows();
	for(new i = 1; i <= bussines; i++)
	{
        new b = i - 1;
		BizzInfo[i][bID]                            = cache_get_value_name_int(b, "ID");
        BizzInfo[i][bOwned]							= cache_get_value_name_int(b, "Owned");
        cache_get_value_name(b, "Owner", BizzInfo[i][bOwner], SQL, 130);
        cache_get_value_name(b, "Message", BizzInfo[i][bMessage], SQL, 130);
   	    BizzInfo[i][bEntranceX]                     = cache_get_value_name_float(b, "EntranceX");
    	BizzInfo[i][bEntranceY]                     = cache_get_value_name_float(b, "EntranceY");
        BizzInfo[i][bEntranceZ]                     = cache_get_value_name_float(b, "EntranceZ");
        BizzInfo[i][bExitX]                         = cache_get_value_name_float(b, "ExitX");
        BizzInfo[i][bExitY]                         = cache_get_value_name_float(b, "ExitY");
        BizzInfo[i][bExitZ]                         = cache_get_value_name_float(b, "ExitZ");
        BizzInfo[i][bLevelNeeded]                   = cache_get_value_name_int(b, "LevelNeeded");
        BizzInfo[i][bBuyPrice]                      = cache_get_value_name_int(b, "BuyPrice");
        BizzInfo[i][bEntranceCost]                  = cache_get_value_name_int(b, "EntranceCost");
        BizzInfo[i][bTill]                          = cache_get_value_name_int(b, "Till");
        BizzInfo[i][bLocked]                        = cache_get_value_name_int(b, "Locked");
        BizzInfo[i][bInterior]                      = cache_get_value_name_int(b, "Interior");
        BizzInfo[i][bVirtual]                       = cache_get_value_name_int(b, "Virtual");
		BizzInfo[i][bSbiz]							= cache_get_value_name_int(b, "Sbiz");
		BizzInfo[i][bType]							= cache_get_value_name_int(b, "Type");
I got this: error 017: undefined symbol "cache_get_value_name_float", but I found that function on R40 wiki...
Also I got these:
Code:
				else if(IsPlayerInRangeOfPoint(playerid,25.0,BizzInfo[49][bEntranceX],BizzInfo[49][bEntranceY],BizzInfo[49][bEntranceZ]))
				{
					BizzInfo[49][bTill] += FillUp;
		    		mysql_format(SQL,str,sizeof(str),"UPDATE `bizz` SET `Till`='%d' WHERE `ID`='49'",BizzInfo[49][bTill]);
					mysql_tquery(SQL,str,"","");
				}
warning 213: tag mismatch: expected tag none ("_"), but found "MySQL"
So what should I do to fix em all?
StRaffael is offline   Reply With Quote
Old 19/10/2018, 06:50 PM   #4
Calisthenics
Huge Clucker
 
Join Date: May 2018
Posts: 349
Reputation: 52
Default Re: Upgrading BluG's MySQL r33 plugin to R40+

The version of a_mysql.inc is not R40 or above. Update plugin and include files again.

https://github.com/pBlueG/SA-MP-MySQL/releases

I also noticed the iteration variable `i` starting from value 1. Why? Array indexes start from 0.
A player name can be up to 24 characters, 130 is overkill.
Calisthenics is offline   Reply With Quote
Old 19/10/2018, 07:48 PM   #5
StRaffael
Little Clucker
 
Join Date: Jan 2016
Posts: 6
Reputation: 0
Default Re: Upgrading BluG's MySQL r33 plugin to R40+

Quote:
Originally Posted by Calisthenics View Post
The version of a_mysql.inc is not R40 or above. Update plugin and include files again.

https://github.com/pBlueG/SA-MP-MySQL/releases

I also noticed the iteration variable `i` starting from value 1. Why? Array indexes start from 0.
A player name can be up to 24 characters, 130 is overkill.
The caracters aren't for players, but for different variables. Anyway, I didn't made the code, and I'm a very begginer to sql language and pawn too...and I am very sure that I downloaded R41-4 version...
StRaffael is offline   Reply With Quote
Old 19/10/2018, 07:58 PM   #6
Calisthenics
Huge Clucker
 
Join Date: May 2018
Posts: 349
Reputation: 52
Default Re: Upgrading BluG's MySQL r33 plugin to R40+

The warning from the community compiler is very clear:
pawn Code:
warning 213: tag mismatch: expected tag none ("_"), but found "MySQL"
It expected:
pawn Code:
new SQL;
but found:
pawn Code:
new MySQL: SQL;
The connection handle until R39 did not have the MySQL: tag so it included an older version. Try opening the script through the editor.
Calisthenics is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Upgrading mysql version Bailews Scripting Help 4 10/06/2017 04:32 PM
[MySQL] From StickenKid's plugin to BlueG's plugin jessejanssen Scripting Help 2 15/06/2014 01:20 AM
MySQL r7 upgrading to new MySQL 2.1.1 BullseyeHawk Scripting Help 0 26/01/2013 05:27 AM
Mysql Upgrading Xizen Help Archive 4 19/03/2011 05:46 AM
mysql plugin. loading plugin failed ikkentim Help Archive 2 10/02/2011 02:32 PM


All times are GMT. The time now is 11:30 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.