diff options
author | David Sommerseth <dazo@users.sourceforge.net> | 2009-09-01 18:46:52 +0200 |
---|---|---|
committer | David Sommerseth <dazo@users.sourceforge.net> | 2009-09-01 18:46:52 +0200 |
commit | 42a6c774802371482cc008caba1168ad274a8687 (patch) | |
tree | 8608b73c1c13fab22fc28588a010326320b15a1c /database/sqlite/sqlite.c | |
parent | 2fcbada9a862ee19a77ee0505452ebed1f3926b1 (diff) | |
download | eurephia-42a6c774802371482cc008caba1168ad274a8687.tar.gz eurephia-42a6c774802371482cc008caba1168ad274a8687.tar.xz eurephia-42a6c774802371482cc008caba1168ad274a8687.zip |
SQLite3 - Added support for "affected rows" count on INSERT/UPDATE/DELETE queries
Diffstat (limited to 'database/sqlite/sqlite.c')
-rw-r--r-- | database/sqlite/sqlite.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/database/sqlite/sqlite.c b/database/sqlite/sqlite.c index 0bc6bb2..ab94783 100644 --- a/database/sqlite/sqlite.c +++ b/database/sqlite/sqlite.c @@ -242,6 +242,11 @@ dbresult *sqlite_query(eurephiaCTX *ctx, char *fmt, ... ) { if( strcasestr(sql, "INSERT INTO") != NULL) { glob_results->last_insert_id = sqlite3_last_insert_rowid((sqlite3 *) dbc->dbhandle); }; + if( strcasestr(sql, "SELECT ") == NULL ) { + // If not a SELECT query, then get the number of affected records + glob_results->affected_rows = sqlite3_changes((sqlite3 *) dbc->dbhandle); + } + glob_results->srch_tuples = glob_results->tuples; glob_results->srch_headerrec = glob_results->headerrec; sqlite3_free(sql); sql = NULL; @@ -544,6 +549,11 @@ int sqlite_get_numtuples(dbresult *res) { return (res != NULL ? res->num_tuples : 0); } +// Retrieve number of tuples in current dbresult structure +int sqlite_get_affected_rows(dbresult *res) { + return (res != NULL ? res->affected_rows : 0); +} + #ifdef SQLITE_DEBUG // Just a simple test program ... to debug this sqlite wrapper int main() { |