mysql newer version
#1

Could anyone for example transfer this to R39-5 version, I use R5 before and now transfering to newer version but this part I just can't.

Код:
stock LoadFuelInfo()
{
	new string[256];
	mysql_tquery(g_iHandle, "SELECT * FROM `duomenys`" );
    mysql_store_result();
    new i = 0,
		siuksle;
    while(mysql_fetch_row(string) == 1)
	{
		sscanf(string,"p<|>dddd", siuksle, vBakas[ i ], vValgo[ i ], vSlotai[ i ] );
		i++;
	}
	mysql_free_result( );
	return 1;
}
while(mysql_fetch_row(string) == 1) I can't find anything to change this part, so if someone could please transfer whole this code into newer version that I would understand, thanks.
Reply
#2

please?
Reply
#3

I don't know what "siuksle" is for but you only assign a value to it, you never actually use it. With threaded queries, the code becomes:
PHP код:
LoadFuelInfo() return mysql_tquery(g_iHandle"SELECT * FROM `duomenys`""OnFuelInfoLoad""");
forward OnFuelInfoLoad();
public 
OnFuelInfoLoad()
{
    new 
siuksle;
    for (new 
icache_get_row_count(); != ji++) // loops through the rows
    
{
        
// cache_get_row_int(rowid, fieldid);
        
siuksle cache_get_row_int(i0);
        
vBakas[i] = cache_get_row_int(i1);
        
vValgo[i] = cache_get_row_int(i2);
        
vSlotai[i] = cache_get_row_int(i3);
    }

Reply
#4

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
I don't know what "siuksle" is for but you only assign a value to it, you never actually use it. With threaded queries, the code becomes:
PHP код:
LoadFuelInfo() return mysql_tquery(g_iHandle"SELECT * FROM `duomenys`""OnFuelInfoLoad""");
forward OnFuelInfoLoad();
public 
OnFuelInfoLoad()
{
    new 
siuksle;
    for (new 
icache_get_row_count(); != ji++) // loops through the rows
    
{
        
// cache_get_row_int(rowid, fieldid);
        
siuksle cache_get_row_int(i0);
        
vBakas[i] = cache_get_row_int(i1);
        
vValgo[i] = cache_get_row_int(i2);
        
vSlotai[i] = cache_get_row_int(i3);
    }

Im very thankful for your help it works very good, could you do one more last example?


Код:
stock LoadSellCars( )
{
	new string[ 126 ];
	mysql_tquery(g_iHandle, "SELECT * FROM `sellcars` ORDER BY `Price` ASC" );
	new id = 0;
	while( cache_get_row( string ) )
	{
	    sscanf( string, "p<|>dd", SellCars[ id ][ 0 ], SellCars[ id ][ 1 ] );
	    id ++;
	}
return 1;
}
Reply
#5

It's better to do an attempt so you can practice the new functions as well. You still have many rows so the loop is the same as previously and you split 2 columns ("d" specifier is for integer type) with sscanf so call cache_get_row_int with fieldid 0 and assign the value returned to SellCars[id][0] and call the same function again with fieldid 1 and assign to SellCars[id][1].
Reply
#6

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
It's better to do an attempt so you can practice the new functions as well. You still have many rows so the loop is the same as previously and you split 2 columns ("d" specifier is for integer type) with sscanf so call cache_get_row_int with fieldid 0 and assign the value returned to SellCars[id][0] and call the same function again with fieldid 1 and assign to SellCars[id][1].
I most understand looking at the diffrence sorry if im asking too much, but if u can. I know it's almost same but this function uses (string ) could you do for example, thanks man..
Reply
#7

The string was only used in the older version to fetch the row and later split it to parts. As long as you load integer and floating-point numbers, you don't need a string.

PHP код:
LoadSellCars return mysql_tquery(g_iHandle"SELECT * FROM `sellcars` ORDER BY `Price` ASC""OnSellCarsLoad""");

forward OnSellCarsLoad();
public 
OnSellCarsLoad()
{
    for (new 
icache_get_row_count(); != ji++)
    {
        
SellCars[i][0] = cache_get_row_int(i0);
        
SellCars[i][1] = cache_get_row_int(i1);
    }

For additional information, you can view the wiki which describes the functions and their parameters: https://sampwiki.blast.hk/wiki/MySQL/R33
Reply
#8

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
The string was only used in the older version to fetch the row and later split it to parts. As long as you load integer and floating-point numbers, you don't need a string.

PHP код:
LoadSellCars return mysql_tquery(g_iHandle"SELECT * FROM `sellcars` ORDER BY `Price` ASC""OnSellCarsLoad""");
forward OnSellCarsLoad();
public 
OnSellCarsLoad()
{
    for (new 
icache_get_row_count(); != ji++)
    {
        
SellCars[i][0] = cache_get_row_int(i0);
        
SellCars[i][1] = cache_get_row_int(i1);
    }

For additional information, you can view the wiki which describes the functions and their parameters: https://sampwiki.blast.hk/wiki/MySQL/R33
Thanks sir, how should I represent SELECT if there's a 3 loads in this callback.

Код:
stock LoadSellCars( )
{
	new string[ 126 ];
	mysql_tquery(g_iHandle, "SELECT * FROM `sellcars` ORDER BY `Price` ASC" );
	new id = 0;
	while( cache_get_row( string ) )
	{
	    sscanf( string, "p<|>dd", SellCars[ id ][ 0 ], SellCars[ id ][ 1 ] );
	    id ++;
	}
	mysql_free_result( );
 	mysql_tquery(g_iHandle, "SELECT * FROM `sellbikes` ORDER BY `Price` ASC" );
	id = 0;
	while( mysql_fetch_row( string ) )
	{
	    sscanf( string, "p<|>dd", SellBikes[ id ][ 0 ], SellBikes[ id ][ 1 ] );
	    id ++;
	}
	mysql_tquery(g_iHandle, "SELECT * FROM `sellsport` ORDER BY `Price` ASC" );
	id = 0;
	while( mysql_fetch_row( string ) )
	{
	    sscanf( string, "p<|>dd", SportCars[ id ][ 0 ], SportCars[ id ][ 1 ] );
	    id ++;
	}
	return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)