diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-04-30 00:27:27 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-04-30 00:27:27 +0100 |
commit | f634bafc38bb948e41f829b16f03e2f0b8ee8f93 (patch) | |
tree | c4f8ff17614b68531355e8047d81e96719101d10 /libsqlitepp/modifycommand.cpp | |
parent | Ignore Vim swap files (diff) | |
download | libdbpp-sqlite-f634bafc38bb948e41f829b16f03e2f0b8ee8f93.tar.bz2 libdbpp-sqlite-f634bafc38bb948e41f829b16f03e2f0b8ee8f93.tar.xz libdbpp-sqlite-f634bafc38bb948e41f829b16f03e2f0b8ee8f93.zip |
Adds support for SQLite, SQLite mocking and some basic tests
Diffstat (limited to 'libsqlitepp/modifycommand.cpp')
-rw-r--r-- | libsqlitepp/modifycommand.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/libsqlitepp/modifycommand.cpp b/libsqlitepp/modifycommand.cpp new file mode 100644 index 0000000..1b44cf4 --- /dev/null +++ b/libsqlitepp/modifycommand.cpp @@ -0,0 +1,31 @@ +#include "modifycommand.h" +#include "error.h" +#include <stdlib.h> +#include "connection.h" + +SQLite::ModifyCommand::ModifyCommand(const Connection * conn, const std::string & sql) : + DB::Command(sql), + DB::ModifyCommand(sql), + SQLite::Command(conn, sql) +{ +} + +SQLite::ModifyCommand::~ModifyCommand() +{ +} + +unsigned int +SQLite::ModifyCommand::execute(bool anc) +{ + if (sqlite3_step(stmt) != SQLITE_DONE) { + sqlite3_reset(stmt); + throw Error(sqlite3_errmsg(c->db)); + } + unsigned int rows = sqlite3_changes(c->db); + sqlite3_reset(stmt); + if (rows == 0 && !anc) { + throw Error("No rows affected"); + } + return rows; +} + |