help with mysql
#1

Here I have the old code which is supported in old mysql, i want it to convert it to new mysql,
I need help in converting to new mysql r39 format. I knew new mysql makes scripting alot easier...

eg:
this is the way the code looks, convert this to new mysql format
pawn Код:
createClanDialog(playerid)
{
    new content[975];
    new Clan[7],score;
    new query[80],string[10];
    mysql_format(mysql,query,sizeof(query),"SELECT `Clan`,`Clanscore` FROM `clans` ORDER BY `Clanscore` DESC LIMIT 30");
    mysql_query(query);
    mysql_store_result();
    if(mysql_num_rows() > 0)
    {
        while(mysql_fetch_row(string,"|"))
        {
            sscanf(string,"p<|>s[7]i",Clan,score);
            format(content,sizeof(content),"%s%s\t\t%d Score\n",content,Clan,score);
        }
    }
    else if(AdminLevel{playerid} < 4) return SendLangMessage(playerid, _COLOR_RED, "Es gibt keine Clans!","There are no Clans!","No hay clanes!");
    mysql_free_result();
    if(AdminLevel{playerid} >= 4)
    {
        switch(Sprache[playerid])
        {
            case 0: format(content, sizeof(content), "%sClan hinzufьgen\n", content);
            case 1: format(content, sizeof(content), "%sAdd Clan\n", content);
            case 2: format(content, sizeof(content), "%sAgregar clan\n", content);
        }
    }
    switch(Sprache[playerid])
    {
        case 0: ShowPlayerDialog(playerid,2001,DIALOG_STYLE_LIST,"Clan Liste",content,"Akzeptieren", "Abbruch");
        case 1: ShowPlayerDialog(playerid,2001,DIALOG_STYLE_LIST,"Clan List",content,"Accept", "Cancel");
        case 2: ShowPlayerDialog(playerid,2001,DIALOG_STYLE_LIST,"Lista del clan",content,"Aceptar","Cerrar");
    }
    return 1;
}
Reply
#2

And what exactly do you expect us to do? Convert it for you?

Take a look at the following functions:
https://sampwiki.blast.hk/wiki/MySQL/R33#mysql_format
https://sampwiki.blast.hk/wiki/MySQL/R33#mysql_tquery
https://sampwiki.blast.hk/wiki/MySQL/R33#cache_get_data
https://sampwiki.blast.hk/wiki/MySQL/R33..._field_content
https://sampwiki.blast.hk/wiki/MySQL/R33...ld_content_int
https://sampwiki.blast.hk/wiki/MySQL/R33..._content_float

And the following topic:
https://sampforum.blast.hk/showthread.php?tid=569088

And there are probably a lot more.
Reply
#3

Yup bible, i want to covert it for me, i have knowledge about all these things... but if i'm done with the sample code i'll take example like that, understand and convert it on my own..
Reply
#4

-bump-

by the way I've converted the code, and I want this to be checked

pawn Код:
createClanDialog(playerid)
{
    new content[975];
    new Clan[7],score;
    new query[80],string[10];
    new rows, fields;
    cache_get_data(rows, fields, mysql);
    mysql_format(mysql,query,sizeof(query),"SELECT `Clan`,`Clanscore` FROM `clans` ORDER BY `Clanscore` DESC LIMIT 30");
    mysql_tquery(mysql,query,"","");
    if(cache_num_rows(mysql) > 0)
    {
        while(cache_get_row(0,0,string))
        {
            sscanf(string,"p<|>s[7]i",Clan,score);
            format(content,sizeof(content),"%s%s\t\t%d Score\n",content,Clan,score);
        }
    }
    else if(AdminLevel{playerid} < 4) return SendLangMessage(playerid, _COLOR_RED, "Es gibt keine Clans!","There are no Clans!","No hay clanes!");
    if(AdminLevel{playerid} >= 4)
    {
        switch(Sprache[playerid])
        {
            case 0: format(content, sizeof(content), "%sClan hinzufen\n", content);
            case 1: format(content, sizeof(content), "%sAdd Clan\n", content);
            case 2: format(content, sizeof(content), "%sAgregar clan\n", content);
        }
    }
    switch(Sprache[playerid])
    {
        case 0: ShowPlayerDialog(playerid,2001,DIALOG_STYLE_LIST,"Clan Liste",content,"Akzeptieren", "Abbruch");
        case 1: ShowPlayerDialog(playerid,2001,DIALOG_STYLE_LIST,"Clan List",content,"Accept", "Cancel");
        case 2: ShowPlayerDialog(playerid,2001,DIALOG_STYLE_LIST,"Lista del clan",content,"Aceptar","Cerrar");
    }
    return 1;
}
Reply
#5

It's threaded queries so you have to execute the query and do some coding inside the public function you used as the example here: https://sampwiki.blast.hk/wiki/MySQL/R33#mysql_tquery

AndreT's tutorial is really good and I recommend you to read it so you have understand the threaded queries: https://sampforum.blast.hk/showthread.php?tid=337810

Read also the loading part, modify your code and post the new results so we can tell you if it's correct and help you with it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)