get_nth_id()
This commit is contained in:
parent
0680837c8c
commit
375b92e487
@ -26,3 +26,12 @@ static const char set_repo_stmt_template[] =
|
||||
static const char dump_stmt[] =
|
||||
"SELECT * FROM project;"
|
||||
;
|
||||
|
||||
static sqlite3_stmt* get_nth_id_stmt;
|
||||
static const char get_nth_id_stmt_template[] =
|
||||
"SELECT rowid "
|
||||
"FROM projects "
|
||||
"WHERE"
|
||||
"LIMIT 1 "
|
||||
"OFFSET ?;"
|
||||
;
|
||||
|
12
src/api.c
12
src/api.c
@ -35,6 +35,7 @@ api_init(void)
|
||||
DBERR(sqlite3_open(DBFILE, &connection));
|
||||
DBERR(stmt_prepare(remind_stmt));
|
||||
DBERR(stmt_prepare(set_repo_stmt));
|
||||
DBERR(stmt_prepare(get_nth_id_stmt));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -42,6 +43,8 @@ DECL void
|
||||
api_rope(void)
|
||||
{
|
||||
DBERR(sqlite3_finalize(remind_stmt));
|
||||
DBERR(sqlite3_finalize(set_repo_stmt));
|
||||
DBERR(sqlite3_finalize(get_nth_id_stmt));
|
||||
sqlite3_close(connection);
|
||||
}
|
||||
|
||||
@ -152,3 +155,12 @@ get_project_count(){
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
DECL int
|
||||
get_nth_id(const int i){
|
||||
int r;
|
||||
DBERR(sqlite3_bind_int(get_nth_id_stmt, 1, i));
|
||||
DBERR(sqlite3_step(get_nth_id_stmt));
|
||||
r = sqlite3_column_int(get_nth_id_stmt, 0);
|
||||
return r;
|
||||
}
|
||||
|
Reference in New Issue
Block a user