good day today park
This commit is contained in:
parent
77d401e8d3
commit
f573ffcf65
2 changed files with 29 additions and 7 deletions
|
@ -36,13 +36,32 @@ sosc::db::Query::Query() : results(this) {
|
|||
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->SetQuery(query);
|
||||
this->SetQuery(query, db);
|
||||
}
|
||||
|
||||
void sosc::db::Query::SetQuery(const std::string &query) {
|
||||
this->Close();
|
||||
void sosc::db::Query::SetQuery(const std::string &query, int db) {
|
||||
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;
|
||||
|
||||
|
||||
}
|
|
@ -9,6 +9,9 @@
|
|||
#define DB_COL_TEXT 1
|
||||
#define DB_COL_BLOB 2
|
||||
|
||||
#define DB_USE_HARD 1
|
||||
#define DB_USE_MEMORY 2
|
||||
|
||||
namespace sosc {
|
||||
namespace db {
|
||||
class Query;
|
||||
|
@ -40,8 +43,8 @@ std::string ResultSet::Get<std::string>(int column, int type = DB_COL_TEXT);*/
|
|||
class Query {
|
||||
public:
|
||||
Query();
|
||||
Query(const std::string& query);
|
||||
void SetQuery(const std::string& query);
|
||||
Query(const std::string& query, int db = DB_USE_HARD);
|
||||
void SetQuery(const std::string& query, int db = DB_USE_HARD);
|
||||
|
||||
void NonQuery();
|
||||
|
||||
|
|
Loading…
Reference in a new issue