SAPE ERROR: Не могу подключиться к серверу: dispenser-01.saperu.net/code.php?user=836f97673aa6aa25a35b5029263ee232&host=amxxmodx.ru&charset=windows-1251&format=serialize, type: file_get_contents

SAPE ERROR: Не могу подключиться к серверу: dispenser-02.saperu.net/code.php?user=836f97673aa6aa25a35b5029263ee232&host=amxxmodx.ru&charset=windows-1251&format=serialize, type: file_get_contents

SQL_NextRow SQL_ReadResult 2. . » AmxModX
| |
 RSS
  • OnLine

    : 4
    : 1
    : -
    : crawl Bot, Yandex Bot, robot Bot

    ?

    • AMX Mod X
    • up.org.ua


  • : Admin : 29-11-2011, 09:47 : 3724

    SQL_NextRow SQL_ReadResult 2. .

    SQL_NextRow , . , .

    sqlx.inc:
    /**
    * Advances to the next result (return value should be ignored).
    */
    native SQL_NextRow(Handle:query);


    :
    SQL_NextRow ( Handle:query )

    • Handle:query -


    :
    Native

    :
    /* Plugin generated by AMXX-Studio */

    #include <amxmodx>
    #include <amxmisc>
    #include <sqlx>

    #define PLUGIN "[SQLx.inc] SQL_NextRow and SQL_ReadResult"
    #define VERSION "1.0"
    #define AUTHOR "Admin"

    new Handle:SQL_Tuple
    new Handle:SQL_Connection

    public plugin_init() {
        
        register_plugin(PLUGIN, VERSION, AUTHOR)
        register_cvar("SQLx_host","127.0.0.1")
        register_cvar("SQLx_db","amxxmodx")
        register_cvar("SQLx_user","admin")
        register_cvar("SQLx_password","pass")
        
        register_concmd("select_sql","sqlx_select")
    }
    public plugin_cfg(){
        new host[33],dbase[33],user[33],pass[33]
        get_cvar_string("SQLx_host",host,30)
        get_cvar_string("SQLx_db",dbase,30)
        get_cvar_string("SQLx_user",user,30)
        get_cvar_string("SQLx_password",pass,30)
        SQL_Tuple = SQL_MakeDbTuple(host,user,pass,dbase) //
        new err, error[256]
        SQL_Connection = SQL_Connect(SQL_Tuple, err, error, charsmax(error)) //
        
        if(SQL_Connection != Empty_Handle)
        {
            log_amx("[SQLx connect ok]") //
            }else{
            log_amx("[SQLX sql error] %s ",error) // ()
            pause("a")
        }
        
    }
    public sqlx_select(id){
        
        //
        new Handle:query = SQL_PrepareQuery(SQL_Connection,"SELECT * FROM `dle_files`")
        //
        SQL_Execute (query)

        while(SQL_MoreResults(query)){
        
            new id = SQL_ReadResult(query, 0)
            new str[32]
            SQL_ReadResult(query, 1, str, 31)
            new name[32]
            SQL_ReadResult(query, 2, name, 31)
        
            server_print("SQL Select Result: %d %s %s",id,str,name)
            
            SQL_NextRow(query)
        }
    }
    public plugin_end(){

        SQL_FreeHandle(SQL_Connection)

    }


    :
    ?
    :

    : N .

    :
    , .
    3 ( )

    SQL_ReadResult - .
    2 ?

    : () SQL_NextRow.
    , ? 10 10?
    100 1000? .

    while, , , , , , .

    :
    public sqlx_select(id){
        
        //
        new Handle:query = SQL_PrepareQuery(SQL_Connection,"SELECT * FROM `table`")
        //
        SQL_Execute (query)

        //
        while(SQL_MoreResults(query)){
        
            //
            new id = SQL_ReadResult(query, 0)
            new steamid[32]
            SQL_ReadResult(query, 1, steamid, 31)
            new name[32]
            SQL_ReadResult(query, 2, name, 31)

            //
            server_print("SQL Select Result: %d %s %s",id,steamid,name)

            //         
            SQL_NextRow(query)
        }
    }

    , ?
    :
    SQL Select Result: 1 Steamxxx Admin
    SQL Select Result: 2 Steamyyy Player1
    SQL Select Result: 3 Vlalvezzz Player2

    .
    , .
    .
    SQL_NextRow SQL_ReadResult 2. .