Results 1 to 4 of 4

Thread: No clue on how to implement MySQL integration...

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,731
    Thanks
    17
    Thanked 1,082 Times in 683 Posts
    I'm using this:
    PHP Code:
        level.mysql mysql_reuse_connection();
        if(!
    isdefined(level.mysql))
        {
            
    make_global_mysql(hostuserpassdbport);
        }
        
    level.mysql_wrapper = ::mysql_wrapper
    and this as helper:
    PHP Code:

    mysql_wrapper
    (querysaveResults)
    {
        if(!
    isDefined(saveResults))
            
    saveResults false;
        
    mysql level.mysql;
        if(!
    isDefined(mysql))
            return 
    undefined;
        if(
    getcvarint("show_mysql") == 1)
            
    printf("mysql_query:" query "\n");
        
    result mysql_query(mysqlquery);
        
    resettimeout();
        if(
    result)
            return 
    undefined;
        if(
    saveResults)
            return 
    mysql_store_result(mysql);
        return 
    undefined;
    }

    make_global_mysql(hostuserpassdbport)
    {    
        
    mysql mysql_init();
        
    ret mysql_real_connect(mysqlhostuserpassdbport);
        if(!
    ret)
        {
            
    printf("errno=" mysql_errno(mysql) + " error= " mysql_error(mysql) + "\n");
            
    mysql_close(mysql);
            return;
        }
        
    level.mysql mysql;
    }

    stripstring(string)
    {
        return 
    mysql_real_escape_string(level.mysqlstring);

    Then I can just:
    PHP Code:
        result = [[level.mysql_wrapper]]("SELECT mapid FROM mapids WHERE mapname = '" stripstring(mapname) + "'"true);
        if(
    isdefined(result))
        {
            if(
    mysql_num_rows(result))
            {
                
    row mysql_fetch_row(result);
                
    level.mapid int(row[0]);
            }
            
    mysql_free_result(result);
        } 
    Last edited by IzNoGoD; 13th November 2015 at 16:23.
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  2. The Following 2 Users Say Thank You to IzNoGoD For This Useful Post:

    Kemi (10th May 2017),kung foo man (13th November 2015)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •