diff options
author | gabrielgio <gabrielgio@workstation.lan> | 2024-02-17 21:55:15 +0100 |
---|---|---|
committer | gabrielgio <gabrielgio@workstation.lan> | 2024-02-17 21:55:15 +0100 |
commit | f2200e22b05c3801b722cd46617e7bcf64538d17 (patch) | |
tree | c3b6c53b39953cecbb316858c767dfde981051bb /lib/data.c | |
parent | 0a2e62f57734f820cd20e151d1150342408552ed (diff) | |
download | dict-f2200e22b05c3801b722cd46617e7bcf64538d17.tar.gz dict-f2200e22b05c3801b722cd46617e7bcf64538d17.tar.bz2 dict-f2200e22b05c3801b722cd46617e7bcf64538d17.zip |
feat: Add a more "refined" UI
Diffstat (limited to 'lib/data.c')
-rw-r--r-- | lib/data.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -3,9 +3,10 @@ #include <stdio.h> #include "data.h" +#include "../lib/util.h" const char *insert_into = "INSERT INTO words (LINE) VALUES($VVV);"; -const char *select_words = "SELECT Id, Line FROM words WHERE line like $VVV LIMIT 10;"; +const char *select_words = "SELECT Id, Line FROM words WHERE line like $VVV LIMIT $NNN;"; const char *create_table = "CREATE TABLE IF NOT EXISTS words (ID INTEGER PRIMARY KEY AUTOINCREMENT, LINE TEXT NOT NULL);"; Data* new_data(const char* con) @@ -80,7 +81,7 @@ void bootstrap(Data* data) sqlite3_finalize(stmt); } -LIST* data_select(Data* data, char *sch, int len) +LIST* data_select(Data* data, char *sch, int len, int limit) { sqlite3_stmt *stmt; int r = sqlite3_prepare_v2(data->db, select_words, -1, &stmt, NULL); @@ -95,6 +96,7 @@ LIST* data_select(Data* data, char *sch, int len) LIST *list = NULL; sqlite3_bind_text(stmt, 1, sch, len, NULL); + sqlite3_bind_int(stmt, 2, limit); int m = sqlite3_step(stmt); while(m == SQLITE_ROW) { |