本文整理汇总了C++中SqlQuery::query方法的典型用法代码示例。如果您正苦于以下问题:C++ SqlQuery::query方法的具体用法?C++ SqlQuery::query怎么用?C++ SqlQuery::query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SqlQuery
的用法示例。
在下文中一共展示了SqlQuery::query方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get
void get() {
this->response->body.append(blog::layout::header("Gorilla Labs"));
std::string content;
// load the library
bool loadableMod = true;
void* test = dlopen("./libtest.so", RTLD_LAZY);
if (!test) {
std::cout << "Cannot load library: " << dlerror() << std::endl;
loadableMod = false;
// reset errors
dlerror();
}
create_t* create_controller;
destroy_t* destroy_controller;
const char* dlsym_error;
if (loadableMod) {
// load the symbols
create_controller = (create_t*) dlsym(test, "create");
dlsym_error = dlerror();
if (dlsym_error) {
std::cout << "Cannot load symbol create: " << dlsym_error << std::endl;;
loadableMod = false;
}
}
if (loadableMod) {
destroy_controller = (destroy_t*) dlsym(test, "destroy");
dlsym_error = dlerror();
if (dlsym_error) {
std::cout << "Cannot load symbol destroy: " << dlsym_error << std::endl;
loadableMod = false;
}
}
// create an instance of the class
if (loadableMod) {
WebController* cont = create_controller();
cont->get();
destroy_controller(cont);
dlclose(test);
}
sqlite3* db;
int failed = sqlite3_open("utf.sql", &db);
if (failed == 0) {
SqlQuery stmt = SqlQuery(&db);
/*
stmt.exec("CREATE TABLE utf_table (\
col1 INTEGER NOT NULL,\
col2 CHAR(25) NULL,\
col3 VARCHAR(25) NULL,\
col4 NUMERIC NULL,\
col5 TEXT(25) NULL,\
PRIMARY KEY (col1),\
UNIQUE (col2)\
)");
sqlite3_exec(db, "BEGIN", 0, 0, 0);
sqlite3_exec(db, "INSERT INTO utf_table (col3) VALUES('[ˈruskʲɪj jɪˈzɨk]')", 0, 0, 0);
sqlite3_exec(db, "COMMIT", 0, 0, 0);
*/
stmt.query("SELECT col1, col3 FROM utf_table WHERE col3 = ?");
std::string title = "[ˈruskʲɪj jɪˈzɨk]";
stmt.bind(this->request->get("title"));
stmt.fetchAll();
if (!stmt.failed) {
int row_size = stmt.rows.size();
for (int i = 0; i < row_size; i++) {
SqlRow row = stmt.rows[i];
content.append("found id:" + row.get("col1") + ": " + row.get("col3") + "<br />");
}
} else {
content.append("something bad happened");
}
sqlite3_close(db);
} else {
content.append("failed to open db<br />");
}
content.append("<form method='post'><input name='title' /></form><br />" + this->request->get("title"));
this->response->body.append(content);
this->response->body.append(blog::layout::footer());
}