Upgrading BluG's MySQL r33 plugin to R40+
#1

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?
Reply
#2

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://sampwiki.blast.hk/wiki/MySQL/R40
Reply
#3

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?
Reply
#4

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.
Reply
#5

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...
Reply
#6

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)