09.06.2012, 07:54
I am having problems with SQlite...
Here's the saving/loading functions to my script,
And in the Database Viewer, after multiple saves, you start seeing this,
It is like,
is not working, anyone help me?
Here's the saving/loading functions to my script,
Код:
stock SaveServerVariables() { KillTimer(sTimerId); new Query[100], DBResult: Result; sDB = db_open("Server.db"); Result = db_query(sDB, "SELECT * FROM server_settings"); if(db_num_rows(Result) != 1) { format(Query, 100, "DELETE * FROM server_settings"), db_free_result(db_query(sDB, Query)); format(Query, 100, "INSERT INTO server_settings (Name) VALUES ('%s')", sName), db_free_result(db_query(sDB, Query)); } db_free_result(Result); format(Query, 100, "UPDATE server_settings SET Name='%s'", sName), db_free_result(db_query(sDB, Query)); format(Query, 100, "UPDATE server_settings SET Mode='%s'", sMode), db_free_result(db_query(sDB, Query)); format(Query, 100, "UPDATE server_settings SET Map='%s'", sMap), db_free_result(db_query(sDB, Query)); format(Query, 100, "UPDATE server_settings SET Website='%s'", sWebsite), db_free_result(db_query(sDB, Query)); format(Query, 100, "UPDATE server_settings SET Password='%s'", sPassword), db_free_result(db_query(sDB, Query)); format(Query, 100, "UPDATE server_settings SET Year=%d", sYear), db_free_result(db_query(sDB, Query)); format(Query, 100, "UPDATE server_settings SET Month=%d", sMonth), db_free_result(db_query(sDB, Query)); format(Query, 100, "UPDATE server_settings SET Day=%d", sDay), db_free_result(db_query(sDB, Query)); format(Query, 100, "UPDATE server_settings SET Hour=%d", sHour), db_free_result(db_query(sDB, Query)); format(Query, 100, "UPDATE server_settings SET Minute=%d", sMinute), db_free_result(db_query(sDB, Query)); format(Query, 100, "UPDATE server_settings SET Second=%d", sSecond), db_free_result(db_query(sDB, Query)); format(Query, 100, "UPDATE server_settings SET Timestamp=%d", sTimestamp), db_free_result(db_query(sDB, Query)); db_close(sDB); print("The server has saved."); sTimerId = SetTimer("UpdateServer", 500, true); return true; } stock LoadServerVariables() { KillTimer(sTimerId); new DBResult: Query; sDB = db_open("Server.db"); Query = db_query(sDB, "SELECT * FROM server_settings"); if(db_num_rows(Query) != 0) { new Result[100]; db_get_field_assoc(Query, "Name", Result, 100), format(sName, 100, "%s", Result); db_get_field_assoc(Query, "Mode", Result, 100), format(sMode, 100, "%s", Result); db_get_field_assoc(Query, "Map", Result, 100), format(sMap, 100, "%s", Result); db_get_field_assoc(Query, "Website", Result, 100), format(sWebsite, 100, "%s", Result); db_get_field_assoc(Query, "Password", Result, 100), format(sPassword, 100, "%s", Result); db_get_field_assoc(Query, "Year", Result, 100), sYear = strval(Result); db_get_field_assoc(Query, "Month", Result, 100), sMonth = strval(Result); db_get_field_assoc(Query, "Day", Result, 100), sDay = strval(Result); db_get_field_assoc(Query, "Hour", Result, 100), sHour = strval(Result); db_get_field_assoc(Query, "Minute", Result, 100), sMinute = strval(Result); db_get_field_assoc(Query, "Second", Result, 100), sSecond = strval(Result); db_get_field_assoc(Query, "Timestamp", Result, 100), sTimestamp = strval(Result); print("The server has loaded."); } db_free_result(Query); db_close(sDB); sTimerId = SetTimer("UpdateServer", 500, true); return true; }
It is like,
Quote:
"DELETE * FROM server_settings" |