db get_project count // for finding a random one
This commit is contained in:
parent
0d7a6fe891
commit
b7e72910ce
18
src/api.c
18
src/api.c
@ -132,3 +132,21 @@ raw(const char * const sql)
|
||||
} else { strcat(r, "\00"); }
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
static int get_project_count_callback(void* data, int argc, char** argv, char** colname) {
|
||||
(void)argc;
|
||||
(void)colname;
|
||||
int* count = (int*)data;
|
||||
*count = atoi(argv[0]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_project_count(){
|
||||
int r = 0;
|
||||
|
||||
const char* sql = "SELECT COUNT(*) FROM project;";
|
||||
DBERR(sqlite3_exec(connection, sql, get_project_count_callback, &r, NULL));
|
||||
|
||||
return r;
|
||||
}
|
||||
|
Reference in New Issue
Block a user