gstyle to blueg
#1

Hi guys I'm updeteing from gstyle to blueg and I have one question in gstyle there's a function

Код:
mysql_free_result( );
But in blueg I can't find anything something like that, help please
Reply
#2

That's because you have to use the cache feature in BlueG's plugin.

https://sampforum.blast.hk/showthread.php?tid=337810
Reply
#3

Could you show one example in my situation?
Reply
#4

Reading a player:

pawn Код:
public OnPlayerConnect(playerid)
{
    mysql_format(dbHandle, query, sizeof(query), "SELECT * FROM `users` WHERE `username` = '%s' LIMIT 1", Player[playerid][Name]);
    mysql_tquery(dbHandle, query, "OnPlayerLoad", "i", playerid);
}

forward OnPlayerLoad(playerid);
public OnPlayerLoad(playerid)
{
    // cache_num_rows() returns whether there's been a result or not so you can do the following:
    if(cache_num_rows()) {
        // User exists
        // cache_get_field_content_int(0, "columnname"); = retrieves an INT value from the database
        // cache_get_field_content_float(0, "columnname"); = retrieves a FLOAT value from the database
        // cache_get_field_content(0, "columnname", destinationvar, dbHandle, maxsize); = retrieves a STRING from the database
    } else {
        // No user found in the database
    }
    return 1;
}

Getting multiple data rows at once:
pawn Код:
public OnGameModeInit()
{
    mysql_format(dbHandle, query, sizeof(query), "SELECT * FROM `vehicles` LIMIT %d", MAX_DYNAMIC_VEHS);
    mysql_tquery(dbHandle, query, "OnObjectsLoad");
}

forward OnObjectsLoad();
public OnObjectsLoad()
{
    // cache_num_rows() returns whether there's been a result or not so you can do the following:
    // Now we can run through a loop to retrieve all rows database

    for(new i = 0; i < cache_num_rows(); i++)
    {
        // Make sure you use the 'i' variable as it always incerements in the loop in order to read from the rows
        // User exists
        // cache_get_field_content_int(i, "columnname"); = retrieves an INT value from the database
        // cache_get_field_content_float(i, "columnname"); = retrieves a FLOAT value from the database
        // cache_get_field_content(i, "columnname", destinationvar, dbHandle, maxsize); = retrieves a STRING from the database
    }
    return 1;
}
Reply
#5

You don't need mysql_free_result( ); in BlueG.
Reply
#6

@PaulDinam Thanks for help but I asked for sample of my situation mysql_free_result( ); how I should replace this one in blueG with cache?
Reply
#7

Quote:
Originally Posted by sjames
Посмотреть сообщение
You don't need mysql_free_result( ); in BlueG.
Read this? You dont need to replace it with anything.
Reply
#8

Quote:
Originally Posted by sjames
Посмотреть сообщение
Read this? You dont need to replace it with anything.
Thanks it worked, one more question how about this mysql_store_result( ); should I delete this too?
Reply
#9

You don't need it, cache does the work.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)