RSS
热门关键字:  下载  cms  模版  开源  dedecms
当前位置 :| 主页 > 站长学院 > 数据库 > Mysql >

一个Mysql C API小型封装

来源:chinaunix  作者:kevinqing  时间:2006-10-09 Tag: 点击:
主要用于维护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_);
        /

最新评论共有 0 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 密码:
匿名?
注册