File tree Expand file tree Collapse file tree 2 files changed +21
-5
lines changed Expand file tree Collapse file tree 2 files changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -103,7 +103,7 @@ namespace sqlite {
103103 errors::throw_sqlite_error (hresult, sql ());
104104 }
105105 }
106-
106+
107107 std::string sql () {
108108#if SQLITE_VERSION_NUMBER >= 3014000
109109 auto sqlite_deleter = [](void *ptr) {sqlite3_free (ptr);};
@@ -124,7 +124,7 @@ namespace sqlite {
124124 _next_index ();
125125 --_inx;
126126 }
127- execution_started = state;
127+ execution_started = state;
128128 }
129129 bool used () const { return execution_started; }
130130
@@ -373,7 +373,7 @@ namespace sqlite {
373373 Values&&... values
374374 );
375375 }
376-
376+
377377 enum class OpenFlags {
378378 READONLY = SQLITE_OPEN_READONLY,
379379 READWRITE = SQLITE_OPEN_READWRITE,
@@ -449,6 +449,10 @@ namespace sqlite {
449449 return sqlite3_last_insert_rowid (_db.get ());
450450 }
451451
452+ sqlite3_int64 rows_modified () const {
453+ return sqlite3_changes (_db.get ());
454+ }
455+
452456 template <typename Function>
453457 void define (const std::string &name, Function&& func) {
454458 typedef utility::function_traits<Function> traits;
Original file line number Diff line number Diff line change @@ -27,9 +27,21 @@ int main()
2727 std::string sql (" select 1+1" );
2828 long test = 0 ;
2929 db << sql >> test;
30-
30+
3131 if (test != 2 ) exit (EXIT_FAILURE);
32-
32+
33+ db <<" UPDATE foo SET b=? WHERE a=?;" <<" hi" << 1L ;
34+ db << " SELECT b from foo where a=?;" << 1L >> str;
35+ if (str != " hi" )
36+ {
37+ cout << " Bad result on line " << __LINE__ << endl;
38+ exit (EXIT_FAILURE);
39+ }
40+ if (db.rows_modified ()!=1 ) exit (EXIT_FAILURE);
41+
42+ db <<" UPDATE foo SET b=?;" <<" hello world" ;
43+ if (db.rows_modified ()!=2 ) exit (EXIT_FAILURE);
44+
3345 }
3446 catch (sqlite_exception e)
3547 {
You can’t perform that action at this time.
0 commit comments