本文整理匯總了C++中SqlQuery::bind方法的典型用法代碼示例。如果您正苦於以下問題:C++ SqlQuery::bind方法的具體用法?C++ SqlQuery::bind怎麽用?C++ SqlQuery::bind使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SqlQuery
的用法示例。
在下文中一共展示了SqlQuery::bind方法的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());
}