[Help]Saving from mysql to dini [+REP]
#1

I have found a good atm system but i don't know how to change the saving/loading from MYSQL to DINI

PHP код:
public SaveDynamicATMS()
{
        new
                
szQuery[256],
                
iFixID,
                
time GetTickCount(),
                
ATMcount;
 
        
db_query(ATMS"DELETE FROM `ATMS`");
       
        for(new 
i=0i<MAX_ATMSi++) {
                if(
AtmInfo[i][atmTaken] == 1) {
                    
ATMcount++;
                    
format(szQuerysizeof(szQuery), "INSERT INTO `ATMS` (`ID`, `Taken`) VALUES (%d, 1)"iFixID);
                        
db_query(ATMSszQuery);
                       
                        
format(szQuerysizeof(szQuery), "UPDATE `ATMS` SET \
                        X = %f, \
                        Y = %f, \
                        Z = %f, \
                        Angle = %f, \
                        Interior = %d, \
                        VirtualWorld = %d \
                        WHERE ID = %d"
,
                        
AtmInfo[i][atmX],
                        
AtmInfo[i][atmY],
                        
AtmInfo[i][atmZ],
                        
AtmInfo[i][atmAngle],
                        
AtmInfo[i][atmInterior],
                        
AtmInfo[i][atmVirtualWorld],
                        
iFixID);
                       
                        
//printf("[debug] %s", szQuery);
                        
db_query(ATMSszQuery);
                        
iFixID++;
                }
        }
        
printf("%d Dynamic ATMS saved in %dms."ATMcountGetTickCount()-time);
        return 
1;
}
 
public 
LoadDynamicATMS()
{
        new
            
DBResult:dbresult db_query(ATMS"SELECT * FROM `ATMS`"),
            
rows db_num_rows(dbresult),
            
field[20],
            
time GetTickCount();
 
    
//printf("[debug] %s", szQuery);
 
        
if(!rows) {
            return print(
"No rows were found in the ATMs table.");
        }
       
        for(new 
i=0i<rowsi++) {
                
AtmInfo[i][atmTaken] = 1;
                
db_get_field_assoc(dbresult"X"fieldsizeof(field));                                AtmInfo[i][atmX] = floatstr(field);
                
db_get_field_assoc(dbresult"Y"fieldsizeof(field));                                AtmInfo[i][atmY] = floatstr(field);
                
db_get_field_assoc(dbresult"Z"fieldsizeof(field));                                AtmInfo[i][atmZ] = floatstr(field);
                
db_get_field_assoc(dbresult"Angle"fieldsizeof(field));                    AtmInfo[i][atmAngle] = floatstr(field);
                
db_get_field_assoc(dbresult"Interior"fieldsizeof(field));                 AtmInfo[i][atmInterior] = strval(field);
                
db_get_field_assoc(dbresult"VirtualWorld"fieldsizeof(field));             AtmInfo[i][atmVirtualWorld] = strval(field);
                
CreateDynamicATM(i);
                
db_next_row(dbresult);
        }
        
db_free_result(dbresult);
       
        
printf("%d Dynamic ATMS loaded in %dms."rowsGetTickCount()-time);
        return 
1;

the script is here http://pastebin.com/f9qSc9SZ
\
Thanks,
Reply
#2

1) This is SQLite, not MySQL which means you can run it as-is.
2) Dini sucks. Don't use it for any new projects.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)