Linux中国 Linux中国门户站!
设为主页 设为主页
收藏本站 收藏本站
 
当前位置 :首页 ->数据库应用 ->Mysql ->正文

一个Mysql C API小型封装

来源:chinaunix  作者:Webmaster 时间:2007-04-23 点击: [收藏] [投稿]











主要用于维护C结构的查询和返回。

#include 

typedef        std::string        string;

struct        mysql_parm{
        string        host;
        string        user;
        string        password;
        string        database;
        string        unixsock;
};
class        DBSTMT;
class        DBMysql;

class        DBSTMT{
        DBSTMT(const DBSTMT&);
        DBSTMT&        operator=(const DBSTMT&);
        MYSQL_STMT*        stmt_;
public:
        DBSTMT(pcsz_t        query,DBMysql&        mysql);
        void        execute(){
                if(mysql_stmt_execute(stmt_))
                        throw        mysql_stmt_error(stmt_);
        }

        void        execute(MYSQL_BIND* bind){
                if(mysql_stmt_execute(stmt_))
                        throw        mysql_stmt_error(stmt_);
                if(mysql_stmt_bind_result(stmt_,bind)){
                        throw        mysql_stmt_error(stmt_);
                }
                if(mysql_stmt_store_result(stmt_))
                        throw        mysql_stmt_error(stmt_);
        }

        //void        execute(){
        //        if(mysql_stmt_execute(stmt_))
        //                throw        mysql_stmt_error(stmt_);
        /

 如果您对本文有任何疑问或者建议,请到讨论区发表您的意见: >> 论坛入口 <<



上一篇:从MySQL中导出XLS数据库工具   下一篇:CEO褒贬甲骨文 称努力打造产品

文章评论】 【收藏本文】 【推荐好友】 【打印本文】 【我要投稿】 【论坛讨论
更多相关文章