
一个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_);
}
