Problem MYSQL R7
#1

Hi, i want to upgrade my mysql plugin R6 to R7, i want to do it gradually. I want to use cache but not directly for try my query.

Exemply why this query don't work? I read to this post https://sampforum.blast.hk/showthread.php?tid=56564 mysql_num_rows it's okay on R7.

PHP код:
GetUserCreate(playerid)
{
    new 
query[130];
    
format(query,sizeof(query),"SELECT PlayerID FROM `comptes` WHERE Pseudo = '%s' LIMIT 1",GetPlayerNameEx(playerid));
    
mysql_function_query(ConnexionBDDqueryfalse"""");
    
mysql_store_result();
    if(
mysql_num_rows() > 0)
    {
        return 
1;
    }
    
mysql_free_result();
    return 
0;

The log

Quote:

[20:41:00] Passing query SELECT PlayerID FROM `comptes` WHERE Pseudo = 'Soze' LIMIT 1 |
[20:41:00] ProcessQueryThread() - Query was successful. (SELECT PlayerID FROM `dm_comptes` WHERE Pseudo = 'Soze' LIMIT 1)
[20:41:00] CMySQLHandler::ProcessQueryThread() - Data is getting passed to ->ProcessTick()

My GetUserCreate return 0 all times but with R6 version it's okay.
Reply
#2

R7 doesn't need to store or free the result.

You get the result in a response callback.

pawn Код:
mysql_function_query(handle,query,cacheing??,"responsecallback","arguments",Mixed{...)
Example:

pawn Код:
mysql_function_query(MySQL_Handle,"SELECT * FROM `users` WHERE ip="127.0.0.1",true,"r@MySQL_IPs","ds",playerid,"127.0.0.1");
pawn Код:
public r@MySQL_IPs(playerid,ip[])
{
    new rows,fields,pip[16],text[24];
    cache_get_data(rows,fields,handle);
    if(rows)
    {
        SendClientMessage(playerid,-1,"Players with IP '127.0.0.1':");
        for(new f; f = fields; ++f)
        {
            cache_get_field_content(0,"name",pip,handle);
            format(text,sizeof text,"%s",pip);
            SendClientMessage(playerid,-1,text);
        }
    }
    else
        return SendClientMessage(playerid,-1,"No player with this IP.");
    return 1;
}
Reply
#3

Ok thanks, on R7 we are forced to use cache_get_data and other... we can't use the old script?
Reply
#4

Quote:
Originally Posted by HitnKill
Посмотреть сообщение
Ok thanks, on R7 we are forced to use cache_get_data and other... we can't use the old script?
You can manually convert.

This can help you

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

I have an idea for don't change all my script with this vR7 MYSQL.

Example my old function

PHP код:
R6
if(IPBanned(plrip) > 0)
{
  
// code....
}
IPBanned(ip[])
{
    new 
query[100],ipexist;
    
format(query,sizeof(query),"SELECT IP FROM `dm_bans` WHERE IP = '%s' LIMIT 1",ip);
    
mysql_query(query);
    
mysql_store_result();
    new 
rows mysql_num_rows();
    if(
rows 0ipexist 1;
    else 
ipexist 0;
    
mysql_free_result();
     return 
ipexist;

PHP код:
R7
if(IPBanned(plrip,0) > 0)
{
   
// code...
}
forward IPBanned(ip[],ID);
public 
IPBanned(ip[],ID)
{
    if(
ID == 0)
    {
        new 
query[100];
        
format(query,sizeof(query),"SELECT IP FROM `dm_bans` WHERE IP = '%s' LIMIT 1",ip);
        
mysql_function_query(ConnexionBDDquerytrue"IPBanned""si",ip,1);
    }
    else
    {
        new 
rows,fields,ipexist;
        
cache_get_data(rowsfields);
        if(
rows 0ipexist 1;
        else 
ipexist 0;
         return 
ipexist;
     }
     return 
1;

Don't problem with this codes on R7 if i call a same function?
Reply


Forum Jump:


Users browsing this thread: