Re: Rock Band Clone - Update

new topic     » goto parent     » topic index » view thread      » older message » newer message

To extend Pete's comments, here are the typical wrapper functions I use all the time. I especially like db_auto_insert() which auto-numbers the key field for quick-and-dirty insert operations. smile Also, you may want to consider Matt's EuSQL on a project of this size. blink

global function db_load( sequence name, integer mode = DB_LOCK_EXCLUSIVE ) 
     
    integer retval 
     
    retval = db_select( name ) 
    if retval = DB_OK then 
        return retval 
    end if 
     
    retval = db_open( name, mode ) 
    if retval = DB_OK or retval = DB_LOCK_FAIL then 
        return retval 
    end if 
     
    return db_create( name, mode ) 
end function 
 
global function db_load_table( sequence name ) 
     
    integer retval 
     
    retval = db_select_table( name ) 
    if retval = DB_OK then 
        return retval 
    end if 
     
    return db_create_table( name ) 
end function 
 
global function db_auto_insert( object data ) 
     
    integer count, key 
    count = db_table_size() 
     
    if count > 0 then 
        key = db_record_key( count ) 
    else 
        key = 0 
    end if 
     
    return db_insert( key + 1, data ) 
end function 

-Greg

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu