I need an example to convert MySQL R6 to MySQL R7.
#1

Hi everybody,

I'd like your help to convert just one line of MySQL R6 to MySQL R7 cause i dunno how to use it.

MySQL R6 :
PHP Code:
                    format(querysizeof(query), "SELECT `id` FROM `vehicles` WHERE `owner` = '%s' AND `plate` = '15640'"pname);
                    
mysql_query(query);
                    
mysql_store_result();
                    while(
mysql_retrieve_row())
                    {
                        
mysql_fetch_field_row(savingstring"id"); UserInfo[playerid][uVehKey1] = strval(savingstring);
                        
SaveStats(playerid);
                    }
                    
mysql_free_result();
                    new 
rand random(sizeof(VehicleSpawns));
                    
format(querysizeof(query), "UPDATE `vehicles` SET `park_x` = '%f', `park_y` = '%f', `park_z` = '%f' WHERE `id` = '%d'"VehicleSpawns[rand][0], VehicleSpawns[rand][1], VehicleSpawns[rand][2], UserInfo[playerid][uVehKey1]);
                    
mysql_query(query);
                    
format(querysizeof(query), "UPDATE `vehicles` SET `plate` = '*' WHERE `id` = '%d'"UserInfo[playerid][uVehKey1]);
                    
mysql_query(query); 
If you can show me how convert this to MySQL R7.

Thanks a lot!
Reply
#2

pawn Code:
loadVehicle(playerid) {
    format(query, sizeof query, "SELECT `id` FROM `vehicles` WHERE `owner` = '%s' AND `plate` = '15640'", pname);
    mysql_function_query(yourConnectionHandleHere, query, true, "OnVehicleLoad", "d", playerid);
}

forward OnVehicleLoad(playerid);
public OnVehicleLoad(playerid)
{
    new rows, fields;
    cache_get_data(rows, fields);

    if(!rows) return 0;

    new content[11];

    cache_get_row(0, 0, content, yourConnectionHandleHere);
    UserInfo[playerid][uVehKey1] = strval(content);
    SaveStats(playerid);

    new rand = random(sizeof(VehicleSpawns)), query[500];
    format(query, sizeof(query), "UPDATE `vehicles` SET `park_x` = '%f', `park_y` = '%f', `park_z` = '%f' WHERE `id` = '%d'", VehicleSpawns[rand][0], VehicleSpawns[rand][1], VehicleSpawns[rand][2], UserInfo[playerid][uVehKey1]);
    mysql_function_query(yourConnectionHandleHere, query, false, "", "");

    format(query, sizeof(query), "UPDATE `vehicles` SET `plate` = '*' WHERE `id` = '%d'", UserInfo[playerid][uVehKey1]);
    mysql_function_query(yourConnectionHandleHere, query, false, "", "");
    return 1;
}
Reply
#3

Thanks for you help but i forgot one thing,
how to convert that :

PHP Code:
format(querysizeof(query), "INSERT INTO `vehicles` (model, owner, colour1, colour2, price) VALUES('%d', '%s', '%d', '%d', '%d')"vehiclepnamecolor1color2vehicleprice);
                
mysql_query(query); 
My code with your help :
PHP Code:
SafeGivePlayerMoney(playerid, -vehicleprice);
                
GetPlayerName(playeridpname24);
                
format(querysizeof(query), "INSERT INTO `vehicles` (model, owner, colour1, colour2, price) VALUES('%d', '%s', '%d', '%d', '%d')"vehiclepnamecolor1color2vehicleprice);
                
mysql_query(query);
                if(
key1 == 9999) {
                    
format(querysizeof query"SELECT `id` FROM `vehicles` WHERE `owner` = '%s' AND `plate` = '15640'"pname);
                    
mysql_function_query(MUMU_MYSQL_HANDLEquerytrue"OnVehicleLoad""d"playerid);
                } 
Reply
#4

pawn Code:
format(query, sizeof(query), "INSERT INTO `vehicles` (model, owner, colour1, colour2, price) VALUES('%d', '%s', '%d', '%d', '%d')", vehicle, pname, color1, color2, vehicleprice);
mysql_function_query(MUMU_MYSQL_HANDLE, query, false, "", "");
the 'false' parameter is whether or not to enable the cache. You only want to enable the cache when you're fetching data i.e SELECT queries.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)