NexusForce 1.0.0
A rigorously engineered full-stack C++ backend library.
载入中...
搜索中...
未找到
neforce::idb_connect结构体 参考abstract

数据库连接抽象基类 更多...

#include <db_interface.hpp>

类 neforce::idb_connect 继承关系图:
[图例]

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
 检查连接有效性

详细描述

数据库连接抽象基类

提供连接管理、错误处理、存活检测等基础功能。

在文件 db_interface.hpp200 行定义.

成员函数说明

◆ get_alive()

clock_type neforce::idb_connect::get_alive ( ) const
inlinenodiscardnoexcept

获取连接空闲时间

返回
自上次刷新以来的毫秒数

在文件 db_interface.hpp276 行定义.

引用了 neforce::steady_clock::now() , 以及 neforce::time_cast().

◆ native_handle()

virtual void * neforce::idb_connect::native_handle ( )
nodiscardpure virtualnoexcept

◆ refresh_alive()

void neforce::idb_connect::refresh_alive ( )
inlinenoexcept

刷新连接存活时间

标记当前连接为活动状态,用于连接池空闲检测。

在文件 db_interface.hpp270 行定义.

引用了 neforce::steady_clock::now(), refresh_alive() , 以及 neforce::time_cast().

被这些函数引用 refresh_alive().

◆ update()

virtual bool neforce::idb_connect::update ( const string & sql) const
nodiscardpure virtual

执行非查询SQL语句

参数
sqlSQL语句
返回
执行成功返回true

neforce::mysql_connect, neforce::pgsql_connect, neforce::redis_connect , 以及 neforce::sqlite_connect 内被实现.


该结构体的文档由以下文件生成: