|
NexusForce 1.0.0
A rigorously engineered full-stack C++ backend library.
|
数据库连接抽象基类 更多...
#include <db_interface.hpp>
Public 类型 | |
| using | clock_type = milliseconds |
| 存活时间计时器类型 | |
Public 成员函数 | |
| virtual bool | update (const string &sql) const =0 |
| 执行非查询SQL语句 | |
| virtual void * | native_handle () noexcept=0 |
| 获取原生连接句柄 | |
| void | refresh_alive () noexcept |
| 刷新连接存活时间 | |
| clock_type | get_alive () const noexcept |
| 获取连接空闲时间 | |
连接管理 | |
| virtual bool | connect (const db_config &config)=0 |
| 建立连接 | |
| virtual bool | reconnect (const db_config &config)=0 |
| 重新连接 | |
| virtual void | close ()=0 |
| 关闭连接 | |
字符集设置 | |
| virtual bool | set_character_set (const string &encoding)=0 |
| 设置字符集 | |
| virtual string_view | get_character_set () const =0 |
| 获取字符集 | |
错误处理 | |
| virtual string_view | get_error () const =0 |
| 获取错误信息 | |
| virtual uint32_t | get_errno () const =0 |
| 获取错误码 | |
事务管理 | |
| virtual bool | begin ()=0 |
| 开始事务 | |
| virtual bool | commit ()=0 |
| 提交事务 | |
| virtual bool | rollback ()=0 |
| 回滚事务 | |
连接状态检测 | |
| virtual bool | connected () const =0 |
| 检查连接状态 | |
| virtual bool | is_valid () const =0 |
| 检查连接有效性 | |
|
inlinenodiscardnoexcept |
|
nodiscardpure virtualnoexcept |
|
inlinenoexcept |
刷新连接存活时间
标记当前连接为活动状态,用于连接池空闲检测。
在文件 db_interface.hpp 第 270 行定义.
引用了 neforce::steady_clock::now(), refresh_alive() , 以及 neforce::time_cast().
被这些函数引用 refresh_alive().
|
nodiscardpure virtual |
执行非查询SQL语句
| sql | SQL语句 |
在 neforce::mysql_connect, neforce::pgsql_connect, neforce::redis_connect , 以及 neforce::sqlite_connect 内被实现.