16.12.2011, 08:21
Update!
- Added db_open_persistent, db_is_persistent, db_is_valid_persistent, and db_free_persistent.
Persistent databases work exactly the same as ones you open with db_open, except for one thing: you only have to open it once. No, the database won't be constantly open.
Example:
pawn Код:new
DB:g_db
;
public OnGameModeInit() {
g_db = db_open_persistent("mydb.db");
db_query(g_db, "...");
// The db will now close
}
public OnSomethingSomething() {
// SQLitei will detect that the db is closed and open it
db_query(g_db, "...");
// The db is still open
db_query(g_db, "...");
// The db will now close
} - Added db_query_autofree.
This is just like db_query, except it will free the result for you when the current callback finishes executing. No need to use db_free_result.
Note: Do not use db_free_result on results from this function. - Added db_get_field_int and db_get_field_float.
By default, it will fetch field 0. You can add an additional argument to specify another field.
Quickly fetch an integer or float from a result. Example:
pawn Код:new user_count;
user_count = db_fetch_int(db_query_autofree(db, "SELECT COUNT(*) FROM users"));
printf("There are %d users registered.", user_count); - Corrected a few SQLite natives.