helper function to get newest id
This commit is contained in:
parent
5027238879
commit
66c9c45c93
13
src/db.c
13
src/db.c
@ -4,6 +4,19 @@
|
|||||||
|
|
||||||
#include "include/db.h"
|
#include "include/db.h"
|
||||||
|
|
||||||
|
static int get_num_rows(sqlite3* db)
|
||||||
|
{
|
||||||
|
int rows = 0;
|
||||||
|
|
||||||
|
sqlite3_stmt* msg;
|
||||||
|
sqlite3_prepare(db, "SELECT * FROM books;", -1, &msg, NULL);
|
||||||
|
while (sqlite3_step(msg) == SQLITE_ROW)
|
||||||
|
rows++;
|
||||||
|
sqlite3_finalize(msg);
|
||||||
|
|
||||||
|
return rows;
|
||||||
|
}
|
||||||
|
|
||||||
void setup_db(sqlite3* db)
|
void setup_db(sqlite3* db)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user