diff options
-rw-r--r-- | db.c | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -261,11 +261,18 @@ struct db_strings_list db_user_tokens(i64 userid){ bool db_add_token(i64 userid,const char *token){ assert(userid!=-1); + sqlite3_stmt *stmt; + SQLITE(prepare_v2,database,"delete from Firebase where token = ?",-1,&stmt,NULL); + SQLITE(bind_text,stmt,1,token,-1,SQLITE_STATIC); + bool success=sqlite3_step(stmt)==SQLITE_DONE; + SQLITE(finalize,stmt); + if(!success)return false; + SQLITE(prepare_v2,database,"insert into Firebase (user, token) values (?, ?)",-1,&stmt,NULL); SQLITE(bind_int64,stmt,1,userid); SQLITE(bind_text,stmt,2,token,-1,SQLITE_STATIC); - bool success=sqlite3_step(stmt)==SQLITE_DONE; + success=sqlite3_step(stmt)==SQLITE_DONE; SQLITE(finalize,stmt); return success; } |