acl/lib_acl_cpp/include/acl_cpp/db/db_pgsql.hpp

106 lines
1.8 KiB
C++
Raw Normal View History

2018-12-12 11:16:12 +08:00
#pragma once
#include "../acl_cpp_define.hpp"
#include "../stdlib/string.hpp"
#include "../db/db_handle.hpp"
typedef struct pg_conn PGconn;
namespace acl {
class pgsql_conf;
class ACL_CPP_API db_pgsql : public db_handle
{
public:
db_pgsql(const pgsql_conf& conf);
~db_pgsql(void);
static void load(void);
/********************************************************************/
/* <20><><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD> db_handle <20><><EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD> */
/********************************************************************/
const char* dbtype(void) const;
/**
* @override
*/
int get_errno(void) const;
/**
* @override
*/
const char* get_error(void) const;
/**
* @override
*/
bool dbopen(const char* charset = NULL);
/**
* @override
*/
bool is_opened(void) const;
/**
* @override
*/
bool close(void);
/**
* @override
*/
bool tbl_exists(const char* tbl_name);
/**
* @override
*/
bool sql_select(const char* sql, db_rows* result = NULL);
/**
* @override
*/
bool sql_update(const char* sql);
/**
* @override
*/
int affect_count(void) const;
/**
* @override
*/
bool begin_transaction(void);
/**
* @override
*/
bool commit(void);
/**
* @override
*/
bool rollback(void);
private:
char* dbaddr_; // <20><><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
char* dbname_; // <20><><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD>
char* dbuser_; // <20><><EFBFBD>ݿ<EFBFBD><DDBF>˺<EFBFBD>
char* dbpass_; // <20><><EFBFBD>ݿ<EFBFBD><DDBF>˺<EFBFBD><CBBA><EFBFBD><EFBFBD><EFBFBD>
string charset_; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD>õ<EFBFBD><C3B5>ַ<EFBFBD><D6B7><EFBFBD>
int conn_timeout_;
int rw_timeout_;
PGconn* conn_;
int affect_count_;
void sane_pgsql_init(const char* dbaddr, const char* dbname,
const char* dbuser, const char* dbpass, int conn_timeout,
int rw_timeout, const char* charset);
void* sane_pgsql_query(const char* sql);
};
} // namespace acl