上一篇 | 下一篇

一个Mysql C API小型封装

发布: 2008-7-01 09:36 | 作者: admin | 来源: | 查看: 5次

一个Mysql C API小型封装

【字体:小 大】

一个Mysql C API小型封装

作者:不详 文章来源:网络 点击数:1775 更新时间:2007-1-21

主要用于维护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_);

}

字号: | 推荐给好友

71/71234567>

评分:0

我来说两句