mysql update [rep]
#1

hello all
I am converting my Script to Mysql Newest Version.
my current one is now at r5 and i am converting to r40.
i am stuck in the middle.
plz help me to convert these codes ... so i will get an idea of doing it
i had read tutorial but i couldnot understand
PHP код:
public LoadAirline(airlineid)
{
    new 
query[650];
    
format(querysizeof(query), "SELECT * FROM `airlines` WHERE `ID` = '%d'"airlineid);
    
mysql_query(query);
    
mysql_store_result();
    if(
mysql_num_rows() > 0)
    { 
// airline exists
        
new line[1250];
        if(
mysql_fetch_row(line)) //Fetches the line
          
{
              new 
string2[200];
            new 
data[10][128]; //The data strings
              
new data2[17]; //The data variables
              
new Float:data3[4]; //The data floats
              
sscanf(line"p<|>s[128]s[https://sampforum.blast.hk/showthread.ph...6814]dddds[128]s[128]s[128]s[128]s[128]s[128]dddddffffs[128]s[128]dddddddd"data[0], data[1], data2[0], data2[1], data2[2], data2[3], data[2], data[3], data[4], data[5], data[6], data[7], data2[4], data2[5], data2[6], data2[7], data2[8], data3[0],data3[1],data3[2],data3[3],data[8],data[9],data2[9],data2[10],data2[11],data2[12],data2[13],data2[14],data2[15],data2[16]);
            
format(string2sizeof(string2), "%s"data[0]);
            
strmid(AInfo[airlineid][aName], string20strlen(string2), 128);
            
format(string2sizeof(string2), "%s"data[1]);
            
strmid(AInfo[airlineid][aOwner], string20strlen(string2), 128);
            
AInfo[airlineid][aFlights] = data2[0];
            
AInfo[airlineid][aPayrate] = data2[1];
            
AInfo[airlineid][aBalance] = data2[2];
            
AInfo[airlineid][aID] = data2[3];
            
format(string2sizeof(string2), "%s"data[2]);
            
strmid(AInfo[airlineid][aRank1], string20strlen(string2), 128);
            
format(string2sizeof(string2), "%s"data[3]);
            
strmid(AInfo[airlineid][aRank2], string20strlen(string2), 128);
            
format(string2sizeof(string2), "%s"data[4]);
            
strmid(AInfo[airlineid][aRank3], string20strlen(string2), 128);
            
format(string2sizeof(string2), "%s"data[5]);
            
strmid(AInfo[airlineid][aRank4], string20strlen(string2), 128);
            
format(string2sizeof(string2), "%s"data[6]);
            
strmid(AInfo[airlineid][aRank5], string20strlen(string2), 128);
            
format(string2sizeof(string2), "%s"data[7]);
            
strmid(AInfo[airlineid][aRank6], string20strlen(string2), 128);
            
AInfo[airlineid][aTotalEarnt] = data2[4];
            
AInfo[airlineid][aTotalPaid] = data2[5];
            
AInfo[airlineid][aFleetSlots] = data2[6];
            
//AInfo[airlineid][aFleetTotal] = data2[7]; - We don't need to load it, as it's created upon the airline vehicle spawn.
            
AInfo[airlineid][aUniform] = data2[8];
            
AInfo[airlineid][aPos1] = data3[0];
            
AInfo[airlineid][aPos2] = data3[1];
            
AInfo[airlineid][aPos3] = data3[2];
            
AInfo[airlineid][aPos4] = data3[3];
            
format(string2sizeof(string2), "%s"data[8]);
            
strmid(AInfo[airlineid][aMotd], string20strlen(string2), 200);
            
format(string2sizeof(string2), "%s"data[9]);
            
strmid(AInfo[airlineid][aMotdSetBy], string20strlen(string2), 128);
            
AInfo[airlineid][pInvMembers] = data2[9];
            
AInfo[airlineid][pRmvMembers] = data2[10];
            
AInfo[airlineid][pPrmMembers] = data2[11];
            
AInfo[airlineid][pPrkFleet] = data2[12];
            
AInfo[airlineid][pClrFleet] = data2[13];
            
AInfo[airlineid][pBnkPerm] = data2[14];
            
AInfo[airlineid][pRspFleet] = data2[15];
            
AInfo[airlineid][aDistance] = data2[16];
            if(
AInfo[airlineid][aMapIcon] == 0) { AInfo[airlineid][aMapIcon] = CreateDynamicMapIcon(data3[0], data3[1], data3[2], 50); }
            
mysql_free_result();
        }
        
mysql_free_result();
        
//Admin loaded the airline ID: airlineid
    
}
    else
    {
        
mysql_free_result();
        print(
"Failed to load airline.");
    }

Reply
#2

You just have to follow the instructions.
I think the main problem for you is that mysql now uses a callback which means that you need two functions. One function "LoadAirline" to setup the SQL Query but you also need a new callback to fetch the data. Once the callback is called you usually use cache_get_field etc. I think it becomes more clear to you if you read example codes like the login/register mysql tutorial which is on this forum.
Reply
#3

Quote:
Originally Posted by SoLetsGO
Посмотреть сообщение
You just have to follow the instructions.
I think the main problem for you is that mysql now uses a callback which means that you need two functions. One function "LoadAirline" to setup the SQL Query but you also need a new callback to fetch the data. Once the callback is called you usually use cache_get_field etc. I think it becomes more clear to you if you read example codes like the login/register mysql tutorial which is on this forum.
False. Only threaded queries have a callback. If you want to do a non-threaded query then you will need to save the cache and get the stuff from it then delete the cache and you won't need a callback, but it will freeze the server until it finishes that MySQL stuff, but if you use threaded queries then the server will keep going while that MySQL stuff is happening. You can make threaded queries look better by using y_inline though. Also in R40+ it's cache_get_value_name.
Reply
#4

Quote:
Originally Posted by GoldenLion
Посмотреть сообщение
False. Only threaded queries have a callback. If you want to do a non-threaded query then you will need to save the cache and get the stuff from it then delete the cache and you won't need a callback, but it will freeze the server until it finishes that MySQL stuff, but if you use threaded queries then the server will keep going while that MySQL stuff is happening. You can make threaded queries look better by using y_inline though. Also in R40+ it's cache_get_value_name.
Since it's the advantage to use threaded queries in newer MySQL versions, it would make no sense to continue using the old stuff or you could just stay with r5.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)