当前位置: 首页>>代码示例>>C++>>正文


C++ SqlQuery::bind方法代码示例

本文整理汇总了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());
    }
开发者ID:MatiasNAmendola,项目名称:G3DServer,代码行数:85,代码来源:index.cpp


注:本文中的SqlQuery::bind方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。