good day today park

This commit is contained in:
malloc 2018-05-01 17:06:50 -05:00
parent 77d401e8d3
commit f573ffcf65
2 changed files with 29 additions and 7 deletions

View file

@ -36,13 +36,32 @@ sosc::db::Query::Query() : results(this) {
this->open = false; this->open = false;
} }
sosc::db::Query::Query(const std::string& query) : results(this) { sosc::db::Query::Query(const std::string& query, int db) : results(this) {
this->open = false; this->open = false;
this->SetQuery(query); this->SetQuery(query, db);
} }
void sosc::db::Query::SetQuery(const std::string &query) { void sosc::db::Query::SetQuery(const std::string &query, int db) {
this->Close(); if(!_ctx.ready)
return;
if(!this->open)
this->Close();
this->open = true; int status = sqlite3_prepare_v2(
db == DB_USE_MEMORY ? _ctx.mem_db : _ctx.hard_db,
query.c_str(),
query.length() + 1,
&this->statement,
nullptr
);
if(status == SQLITE_OK)
this->open = true;
} }
void sosc::db::Query::NonQuery() {
if(!_ctx.ready || !this->open)
return;
}

View file

@ -9,6 +9,9 @@
#define DB_COL_TEXT 1 #define DB_COL_TEXT 1
#define DB_COL_BLOB 2 #define DB_COL_BLOB 2
#define DB_USE_HARD 1
#define DB_USE_MEMORY 2
namespace sosc { namespace sosc {
namespace db { namespace db {
class Query; class Query;
@ -40,8 +43,8 @@ std::string ResultSet::Get<std::string>(int column, int type = DB_COL_TEXT);*/
class Query { class Query {
public: public:
Query(); Query();
Query(const std::string& query); Query(const std::string& query, int db = DB_USE_HARD);
void SetQuery(const std::string& query); void SetQuery(const std::string& query, int db = DB_USE_HARD);
void NonQuery(); void NonQuery();