Upgrading mysql version
#1

Hello Im trying to update mysql R6 version to R39 I tried search which command change the older one but I couldnt find.

Код:
FUNKCIJA:OnLoadBizzFurnitures( )
{
	new content[ 512 ],
		rows,
		i = 0,
		id,
		count = GetTickCount(),
		furnitureTexture1[30],
		furnitureTexture2[30],
		furnitureTexture3[30],
		furnitureTexture4[30],
		furnitureTexture5[30],
		furnitureNon[] = "-1|-1|-1";

 	mysql_query( "SELECT * FROM `bfurniture`" );
 	mysql_store_result( );
    rows = mysql_num_rows();

	if ( rows )
 	{
		while( mysql_retrieve_row() )
		{
 	        mysql_get_field("Id", content);
			id = strval( content );

			BizzFurniture[ id ][ fId ] = id;

		 	mysql_get_field("ObjectId", content );
		 	BizzFurniture[ id ][ fObjectId ] = strval( content );

			mysql_get_field("BizId", content );
			BizzFurniture[ id ][ fHouseId ] = strval( content );

			mysql_get_field("TxdId0", furnitureTexture1 );
			mysql_get_field("TxdId1", furnitureTexture2 );
			mysql_get_field("TxdId2", furnitureTexture3 );
			mysql_get_field("TxdId3", furnitureTexture4 );
			mysql_get_field("TxdId4", furnitureTexture5 );

			mysql_get_field("Name", BizzFurniture[ id ][ fName ] );

			mysql_get_field("Pos_X", content);
			BizzFurniture[ id ][ fPos ][ 0 ] = floatstr( content );

			mysql_get_field("Pos_Y", content);
			BizzFurniture[ id ][ fPos ][ 1 ] = floatstr( content );

			mysql_get_field("Pos_Z", content);
			BizzFurniture[ id ][ fPos ][ 2 ] = floatstr( content );

			mysql_get_field("Pos_RX", content);
			BizzFurniture[ id ][ frPos ][ 0 ] = floatstr( content );

	 		mysql_get_field("Pos_RY", content);
			BizzFurniture[ id ][ frPos ][ 1 ] = floatstr( content );

			mysql_get_field("Pos_RZ", content);
			BizzFurniture[ id ][ frPos ][ 2 ] = floatstr( content );

	        mysql_get_field("Price", content);
			BizzFurniture[ id ][ fPrice ] = strval( content );

			foreach(Biznes,b)
			{
				if( BizzFurniture[ id ][ fHouseId ] == bInfo[ b ][ bID ] )
				{
				    bfObject[ id ] = CreateDynamicObject( BizzFurniture[ id ][ fObjectId ],
					BizzFurniture[ id ][ fPos ][ 0 ], BizzFurniture[ id ][ fPos ][ 1 ], BizzFurniture[ id ][ fPos ][ 2 ],
					BizzFurniture[ id ][ frPos ][ 0 ], BizzFurniture[ id ][ frPos ][ 1 ], BizzFurniture[ id ][ frPos ][ 2 ],
					BUSINESS_VIRTUAL_WORLD+b );
					break;
				}
			}

			if( strcmp(furnitureTexture1, furnitureNon, false) )
			{
			    new firstID, firstTexture[20], secondTexture[20], oObject, oTxdName[ 18 ], oTextureName[ 18 ], foColour;

			    sscanf(furnitureTexture1, "p<|>ds[20]s[20]", firstID, firstTexture, secondTexture);

				GetDynamicObjectMaterial( bfObject[ id ], 0,
				    oObject, oTxdName, oTextureName, foColour );

			    SetDynamicObjectMaterial(bfObject[ id ], 0,
	            	firstID,
	   				firstTexture,
					secondTexture,
					foColour );
			}
			if( strcmp(furnitureTexture2, furnitureNon, false) )
			{
			    new firstID, firstTexture[20], secondTexture[20], oObject, oTxdName[ 18 ], oTextureName[ 18 ], foColour;

			    sscanf(furnitureTexture2, "p<|>ds[20]s[20]", firstID, firstTexture, secondTexture);

				GetDynamicObjectMaterial( bfObject[ id ], 1,
				    oObject, oTxdName, oTextureName, foColour );

			    SetDynamicObjectMaterial(bfObject[ id ], 1,
	            	firstID,
	   				firstTexture,
					secondTexture,
					foColour );
			}
			if( strcmp(furnitureTexture3, furnitureNon, false) )
			{
			    new firstID, firstTexture[20], secondTexture[20], oObject, oTxdName[ 18 ], oTextureName[ 18 ], foColour;

			    sscanf(furnitureTexture3, "p<|>ds[20]s[20]", firstID, firstTexture, secondTexture);

				GetDynamicObjectMaterial( bfObject[ id ], 2,
				    oObject, oTxdName, oTextureName, foColour );

			    SetDynamicObjectMaterial(bfObject[ id ], 2,
	            	firstID,
	   				firstTexture,
					secondTexture,
					foColour );
			}
			if( strcmp(furnitureTexture4, furnitureNon, false) )
			{
			    new firstID, firstTexture[20], secondTexture[20], oObject, oTxdName[ 18 ], oTextureName[ 18 ], foColour;

			    sscanf(furnitureTexture4, "p<|>ds[20]s[20]", firstID, firstTexture, secondTexture);

				GetDynamicObjectMaterial( bfObject[ id ], 3,
				    oObject, oTxdName, oTextureName, foColour );

			    SetDynamicObjectMaterial(bfObject[ id ], 3,
	            	firstID,
	   				firstTexture,
					secondTexture,
					foColour );
			}
			if( strcmp(furnitureTexture5, furnitureNon, false) )
			{
			    new firstID, firstTexture[20], secondTexture[20], oObject, oTxdName[ 18 ], oTextureName[ 18 ], foColour;

			    sscanf(furnitureTexture5, "p<|>ds[20]s[20]", firstID, firstTexture, secondTexture);

				GetDynamicObjectMaterial( bfObject[ id ], 4,
				    oObject, oTxdName, oTextureName, foColour );

			    SetDynamicObjectMaterial(bfObject[ id ], 4,
	            	firstID,
	   				firstTexture,
					secondTexture,
					foColour );
			}
			i++;
		}
	}
	printf("[BIZNIO BALDAI] Бkrauta %d baldш per %d ms", i, GetTickCount() - count );
}
I need only example how this should be changed to get used to.
Reply
#2

If everyone busy or not looking for help atleast could someone say am I going for right path.

R6:
Код:
		
 	        mysql_get_field("Id", content);
			id = strval( content );

			BizzFurniture[ id ][ fId ] = id;

		 	mysql_get_field("ObjectId", content );
		 	BizzFurniture[ id ][ fObjectId ] = strval( content );
R39:

Код:
id = cache_get_field_content_int(content, "Id");

			BizzFurniture[ id ][ fId ] = id;
			
			
			BizzFurniture[ id ][ fObjectId ] = cache_get_field_content_int(content, "ObjectId");
Please someone reply if im doing something wrong, ty.
Reply
#3

You should use threaded queries, however they're handled differently. They use callbacks, however you can also save cache for later use outside of it with cache_save, cache_set_active, cache_is_valid, etc.

pawn Код:
FUNKCIJA:OnLoadBizzFurnitures( )
    return mysql_tquery(gSQLConnection, "SELECT * FROM bfurniture", "OnLoadBizFurniture", "");

forward OnLoadBizFurniture();
public OnLoadBizFurniture()
{
    new
        // define everything

    if(cache_num_rows())
    {
        for(new i; i <= cache_num_rows(); i++)
        {
            // for strings
            cache_get_field_content(i, "Id", content);

            // for integers
            BizzFurniture[ id ][ fObjectId ] = cache_get_field_content_int(i, "ObjectId");
        }
    }

    printf("... print");
    return true;
}
Reply
#4

Quote:
Originally Posted by Abagail
Посмотреть сообщение
You should use threaded queries, however they're handled differently. They use callbacks, however you can also save cache for later use outside of it with cache_save, cache_set_active, cache_is_valid, etc.

pawn Код:
FUNKCIJA:OnLoadBizzFurnitures( )
    return mysql_tquery(gSQLConnection, "SELECT * FROM bfurniture", "OnLoadBizFurniture", "");

forward OnLoadBizFurniture();
public OnLoadBizFurniture()
{
    new
        // define everything

    if(cache_num_rows())
    {
        for(new i; i <= cache_num_rows(); i++)
        {
            // for strings
            cache_get_field_content(i, "Id", content);

            // for integers
            BizzFurniture[ id ][ fObjectId ] = cache_get_field_content_int(i, "ObjectId");
        }
    }

    printf("... print");
    return true;
}
Код:
rezultatas = mysql_query(Handle, "SELECT * FROM `bfurniture`");
        rows = cache_num_rows();

	if ( rows )
 	{
		while(cache_get_row_count(Handle))
		{
This wouldnt work?

Maybe you could explain why did you create this for(new i; i <= cache_num_rows(); i++)?
Reply
#5

You could use mysql_query, although it's not recommended as it uses the main thread and halts the server until it's been executed. This might be ideal for some purposes, although you should use threading for most. If you're only loading this on server start, using query might be desired so nothing else happens until they've been loaded (Let me know if you want some examples).

Also, the loop is for going through all the rows that have been loaded. You're able to do it this way because the cache_ functions use the row index where i is the current index, e.g:

cache_get_field_content(i, ...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)