#include <db_mysql.hpp>
|
| db_mysql (const char *dbaddr, const char *dbname, const char *dbuser, const char *dbpass, unsigned long dbflags=0, bool auto_commit=true, int conn_timeout=60, int rw_timeout=60, const char *charset="utf8") |
|
| db_mysql (const mysql_conf &conf) |
|
| ~db_mysql (void) |
|
unsigned long | mysql_libversion (void) const |
|
const char * | mysql_client_info (void) const |
|
MYSQL * | get_conn (void) const |
|
const char * | dbtype (void) const |
|
int | get_errno (void) const |
|
const char * | get_error (void) const |
|
bool | dbopen (const char *charset=NULL) |
|
bool | is_opened (void) const |
|
bool | close (void) |
|
bool | tbl_exists (const char *tbl_name) |
|
bool | sql_select (const char *sql, db_rows *result=NULL) |
|
bool | sql_update (const char *sql) |
|
int | affect_count (void) const |
|
bool | begin_transaction (void) |
|
bool | commit (void) |
|
bool | rollback (void) |
|
| db_handle (void) |
|
virtual | ~db_handle (void) |
|
bool | open () |
|
bool | exec_select (query &query, db_rows *result=NULL) |
|
bool | exec_update (query &query) |
|
virtual string & | escape_string (const char *in, size_t len, string &out) |
|
const db_rows * | get_result () const |
|
const std::vector< const db_row * > * | get_rows (const char *name, const char *value) |
|
const std::vector< db_row * > * | get_rows () const |
|
const db_row * | get_first_row () const |
|
void | free_result () |
|
const db_row * | operator[] (size_t idx) const |
|
size_t | length () const |
|
bool | empty () const |
|
void | print_out (size_t max=0) const |
|
db_handle & | set_id (const char *id) |
|
const char * | get_id () const |
|
db_handle & | set_when (time_t now) |
|
time_t | get_when () const |
|
| connect_client (void) |
|
virtual | ~connect_client () |
|
time_t | get_when () |
|
void | set_when (time_t when) |
|
connect_pool * | get_pool () const |
|
virtual void | set_timeout (int conn_timeout, int rw_timeout) |
|
◆ db_mysql() [1/2]
acl::db_mysql::db_mysql |
( |
const char * |
dbaddr, |
|
|
const char * |
dbname, |
|
|
const char * |
dbuser, |
|
|
const char * |
dbpass, |
|
|
unsigned long |
dbflags = 0 , |
|
|
bool |
auto_commit = true , |
|
|
int |
conn_timeout = 60 , |
|
|
int |
rw_timeout = 60 , |
|
|
const char * |
charset = "utf8" |
|
) |
| |
构造函数方式一
- 参数
-
dbaddr | {const char*} 数据库监听地址,可以为 TCP 套接口或在 UNIX 平台下的域套接口,格式如:127.0.0.1:3306,或 /tmp/mysql.sock |
dbname | {const char*} 数据库名称,非 NULL |
dbuser | {const char*} 连接数据库时的用户名 |
dbpass | {const char*} 连接数据库时的用户密码 |
dbflags | {unsigned long} 连接 MYSQL 时的标志位 |
auto_commit | {bool} 当对数据库进行修改时是否自动提交事务 |
conn_timeout | {int} 连接数据库的超时时间(秒) |
rw_timeout | {int} 进行数据库操作时的超时时间(秒) |
charset | {const char*} 连接数据库时的本地字符集(gbk, utf8, ...) |
◆ db_mysql() [2/2]
acl::db_mysql::db_mysql |
( |
const mysql_conf & |
conf | ) |
|
◆ ~db_mysql()
acl::db_mysql::~db_mysql |
( |
void |
| ) |
|
◆ affect_count()
int acl::db_mysql::affect_count |
( |
void |
| ) |
const |
|
virtual |
◆ begin_transaction()
bool acl::db_mysql::begin_transaction |
( |
void |
| ) |
|
|
virtual |
◆ close()
bool acl::db_mysql::close |
( |
void |
| ) |
|
|
virtual |
◆ commit()
bool acl::db_mysql::commit |
( |
void |
| ) |
|
|
virtual |
◆ dbopen()
bool acl::db_mysql::dbopen |
( |
const char * |
charset = NULL | ) |
|
|
virtual |
◆ dbtype()
const char* acl::db_mysql::dbtype |
( |
void |
| ) |
const |
|
virtual |
◆ get_conn()
MYSQL* acl::db_mysql::get_conn |
( |
void |
| ) |
const |
|
inline |
直接获得 mysql 的连接句柄,如果返回 NULL 则表示 mysql 还没有打开 或出错时内部自动关闭了 mysql 连接
- 返回
- {MYSQL*}
在文件 db_mysql.hpp 第 60 行定义.
◆ get_errno()
int acl::db_mysql::get_errno |
( |
void |
| ) |
const |
|
virtual |
◆ get_error()
const char* acl::db_mysql::get_error |
( |
void |
| ) |
const |
|
virtual |
◆ is_opened()
bool acl::db_mysql::is_opened |
( |
void |
| ) |
const |
|
virtual |
◆ load()
static void acl::db_mysql::load |
( |
void |
| ) |
|
|
static |
当动态加载 libmysqlclient.so / libmysqlclient.dll 时,可以调用本 静态函数显式动态加载 mysql 客户端库,如果加载失败,内部会自动产生 断言,以免运行时出错,也可不调用本函数,使 db_mysql 类对象内部在 使用时隐式加载 mysql 动态库
◆ mysql_client_info()
const char* acl::db_mysql::mysql_client_info |
( |
void |
| ) |
const |
获得 mysql 客户端库的信息
- 返回
- {const char*}
◆ mysql_libversion()
unsigned long acl::db_mysql::mysql_libversion |
( |
void |
| ) |
const |
获得 mysql 客户端库的版本号
- 返回
- {unsigned long}
◆ rollback()
bool acl::db_mysql::rollback |
( |
void |
| ) |
|
|
virtual |
◆ sql_select()
bool acl::db_mysql::sql_select |
( |
const char * |
sql, |
|
|
db_rows * |
result = NULL |
|
) |
| |
|
virtual |
◆ sql_update()
bool acl::db_mysql::sql_update |
( |
const char * |
sql | ) |
|
|
virtual |
◆ tbl_exists()
bool acl::db_mysql::tbl_exists |
( |
const char * |
tbl_name | ) |
|
|
virtual |
该类的文档由以下文件生成: