acl
3.5.3.0
|
#include <db_sqlite.hpp>
Public 成员函数 | |
db_sqlite (const char *dbfile, const char *charset="utf-8") | |
~db_sqlite (void) | |
const char * | version (void) const |
bool | set_conf (const char *pragma) |
const char * | get_conf (const char *pragma, string &out) |
void | show_conf (const char *pragma=NULL) |
int | affect_total_count (void) const |
sqlite3 * | get_conn (void) const |
bool | prepare (sqlite_cursor &cursor) |
bool | next (sqlite_cursor &cursor, bool *done) |
int | sqlite3_prepare_v2 (const char *zSql, int nByte, sqlite3_stmt **ppStmt, const char **pzTail) |
int | sqlite3_step (sqlite3_stmt *stmt) |
int | sqlite3_reset (sqlite3_stmt *pStmt) |
int | sqlite3_finalize (sqlite3_stmt *stmt) |
int | sqlite3_bind_blob (sqlite3_stmt *stmt, int iCol, const void *value, int n, void(*destory)(void *)) |
int | sqlite3_bind_int (sqlite3_stmt *stmt, int iCol, int value) |
int | sqlite3_bind_int64 (sqlite3_stmt *stmt, int iCol, long long int value) |
int | sqlite3_bind_text (sqlite3_stmt *stmt, int iCol, const char *value, int n, void(*destory)(void *)) |
int | sqlite3_column_count (sqlite3_stmt *stmt) |
const void * | sqlite3_column_blob (sqlite3_stmt *stmt, int iCol) |
int | sqlite3_column_int (sqlite3_stmt *stmt, int iCol) |
long long int | sqlite3_column_int64 (sqlite3_stmt *stmt, int iCol) |
const unsigned char * | sqlite3_column_text (sqlite3_stmt *stmt, int iCol) |
int | sqlite3_column_bytes (sqlite3_stmt *stmt, int iCol) |
const char * | sqlite3_column_name (sqlite3_stmt *stmt, int iCol) |
int | sqlite3_exec (const char *sql, int(*callback)(void *, int, char **, char **), void *arg, char **errmsg) |
void | sqlite3_free (void *ptr) |
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 | set_busy_timeout (int nMillisecs) |
Public 成员函数 继承自 acl::db_handle | |
db_handle (void) | |
virtual | ~db_handle (void) |
bool | open () |
virtual bool | rollback () |
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 |
Public 成员函数 继承自 acl::connect_client | |
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) |
额外继承的成员函数 | |
静态 Public 成员函数 继承自 acl::db_handle | |
static void | set_loadpath (const char *path) |
static const char * | get_loadpath () |
Protected 成员函数 继承自 acl::connect_client | |
void | set_pool (connect_pool *pool) |
Protected 成员函数 继承自 acl::acl::noncopyable | |
noncopyable () | |
~noncopyable () | |
Protected 属性 继承自 acl::db_handle | |
db_rows * | result_ |
char * | id_ |
time_t | when_ |
Protected 属性 继承自 acl::connect_client | |
int | conn_timeout_ |
int | rw_timeout_ |
time_t | when_ |
connect_pool * | pool_ |
在文件 db_sqlite.hpp 第 16 行定义.
acl::db_sqlite::db_sqlite | ( | const char * | dbfile, |
const char * | charset = "utf-8" |
||
) |
构造函数
charset | {const char*} 本地字符集(gbk, utf-8, ...) |
acl::db_sqlite::~db_sqlite | ( | void | ) |
|
virtual |
@override
实现了 acl::db_handle.
int acl::db_sqlite::affect_total_count | ( | void | ) | const |
自数据库打开后所有的影响的记录行数
|
virtual |
@override
重载 acl::db_handle .
|
virtual |
@override
实现了 acl::db_handle.
|
virtual |
@override
重载 acl::db_handle .
|
virtual |
@override
实现了 acl::db_handle.
|
virtual |
@override
实现了 acl::db_handle.
const char* acl::db_sqlite::get_conf | ( | const char * | pragma, |
string & | out | ||
) |
当数据库打开调用此函数获得数据引擎的配置选项
pragma | {const char*} 配置选项内容,格式为: PRAGMA xxx 如:PRAGMA synchronous |
out | {string&} 如果返回值非空则存储结果 |
|
inline |
直接获得 sqlite 的句柄,如果返回 NULL 则表示 sqlite 还没有打开 或出错时内部自动关闭了 sqlite
在文件 db_sqlite.hpp 第 70 行定义.
|
virtual |
@override
重载 acl::db_handle .
|
virtual |
@override
重载 acl::db_handle .
|
virtual |
@override
实现了 acl::db_handle.
bool acl::db_sqlite::next | ( | sqlite_cursor & | cursor, |
bool * | done | ||
) |
bool acl::db_sqlite::prepare | ( | sqlite_cursor & | cursor | ) |
bool acl::db_sqlite::set_busy_timeout | ( | int | nMillisecs | ) |
@override
bool acl::db_sqlite::set_conf | ( | const char * | pragma | ) |
当数据库打开后通过此函数对数据库的操作引擎进行配置, 进行配置的内容需要严格遵循 sqlite 本身的配置选项要求
pragma | {const char*} 配置选项内容,格式为: PRAGMA xxx=xxx 如:PRAGMA synchronous = NORMAL |
void acl::db_sqlite::show_conf | ( | const char * | pragma = NULL | ) |
在数据库打开的情况下输入数据库引擎的配置选项
pragma | {const char*} 指定的配置选项,如果该参数为空, 则输出所有的配置选项,格式为:PRAGMA xxx,如:PRAGMA synchronous |
|
virtual |
@override
实现了 acl::db_handle.
|
virtual |
@override
实现了 acl::db_handle.
int acl::db_sqlite::sqlite3_bind_blob | ( | sqlite3_stmt * | stmt, |
int | iCol, | ||
const void * | value, | ||
int | n, | ||
void(*)(void *) | destory | ||
) |
绑定二进制数据
stmt | {sqlite3*} prepared statement |
iCol | {int} 待绑定到sql中的参数索引 |
value | {const void*} 待绑定到sql中的参数数值 |
n | {int} 参数的字节长度 |
destory | {void(*)(void*)} 传入参数的析构函数 |
int acl::db_sqlite::sqlite3_bind_int | ( | sqlite3_stmt * | stmt, |
int | iCol, | ||
int | value | ||
) |
绑定int类型数据
stmt | {sqlite3*} prepared statement |
iCol | {int} 待绑定到sql中的参数索引 |
value | {int} 待绑定到sql中的参数数值 |
int acl::db_sqlite::sqlite3_bind_int64 | ( | sqlite3_stmt * | stmt, |
int | iCol, | ||
long long int | value | ||
) |
绑定int64数据
stmt | {sqlite3*} prepared statement |
iCol | {int} 待绑定到sql中的参数索引 |
value | {long long int} 待绑定到sql中的参数数值 |
int acl::db_sqlite::sqlite3_bind_text | ( | sqlite3_stmt * | stmt, |
int | iCol, | ||
const char * | value, | ||
int | n, | ||
void(*)(void *) | destory | ||
) |
绑定text数据
stmt | {sqlite3*} prepared statement |
iCol | {int} 待绑定到sql中的参数索引 |
value | {const void*} 待绑定到sql中的参数数值 |
n | {int} 参数的字节长度 |
destory | {void(*)(void*)} 传入参数的析构函数 |
const void* acl::db_sqlite::sqlite3_column_blob | ( | sqlite3_stmt * | stmt, |
int | iCol | ||
) |
返回查询结果的对应列的二进制结果信息
stmt | {sqlite3_stmt*} prepared statement |
iCol | {int} 列索引 |
int acl::db_sqlite::sqlite3_column_bytes | ( | sqlite3_stmt * | stmt, |
int | iCol | ||
) |
返回查询结果的对应列的结果信息数据字节长度
stmt | {sqlite3_stmt*} prepared statement |
iCol | {int} 列索引 |
int acl::db_sqlite::sqlite3_column_count | ( | sqlite3_stmt * | stmt | ) |
返回 prepared statement 结果集的列数
stmt | {sqlite3_stmt*} prepared statement |
int acl::db_sqlite::sqlite3_column_int | ( | sqlite3_stmt * | stmt, |
int | iCol | ||
) |
返回查询结果的对应列的int结果信息
stmt | {sqlite3_stmt*} prepared statement |
iCol | {int} 列索引 |
long long int acl::db_sqlite::sqlite3_column_int64 | ( | sqlite3_stmt * | stmt, |
int | iCol | ||
) |
返回查询结果的对应列的int64结果信息
stmt | {sqlite3_stmt*} prepared statement |
iCol | {int} 列索引 |
const char* acl::db_sqlite::sqlite3_column_name | ( | sqlite3_stmt * | stmt, |
int | iCol | ||
) |
返回select结果集中特定列的名称
stmt | {sqlite3_stmt*} prepared statement |
iCol | {int} 列索引 |
const unsigned char* acl::db_sqlite::sqlite3_column_text | ( | sqlite3_stmt * | stmt, |
int | iCol | ||
) |
返回查询结果的对应列的 utf-8 text 结果信息
stmt | {sqlite3_stmt*} prepared statement |
iCol | {int} 列索引 |
int acl::db_sqlite::sqlite3_exec | ( | const char * | sql, |
int(*)(void *, int, char **, char **) | callback, | ||
void * | arg, | ||
char ** | errmsg | ||
) |
执行单条sql语句
sql | {const char*} 待执行的sql语句 |
callback | {int (*)(void*,int,char**,char**)} callback函数 |
arg | {void*}callback函数的第一个参数 |
errmsg | {char**} 错误信息 |
int acl::db_sqlite::sqlite3_finalize | ( | sqlite3_stmt * | stmt | ) |
释放 prepared statement 资源
stmt | {sqlite3_stmt*} prepared statement句柄 |
void acl::db_sqlite::sqlite3_free | ( | void * | ptr | ) |
为释放 errmsg 而添加的接口
ptr | {void*} 待释放数据指针 |
int acl::db_sqlite::sqlite3_prepare_v2 | ( | const char * | zSql, |
int | nByte, | ||
sqlite3_stmt ** | ppStmt, | ||
const char ** | pzTail | ||
) |
将zSql初始化为 prepared statement
zSql | {const char*} utf-8编码的sql |
nByte | {int} zSql的最大字节长度 |
ppStmt | {sqlite3_stmt**} OUT: prepared statement句柄 |
pzTail | {const char**} OUT: 指向zSql未使用部分的指针 |
int acl::db_sqlite::sqlite3_reset | ( | sqlite3_stmt * | pStmt | ) |
将prepared statement重置为初始化状态
pStmt | {sqlite3_stmt*} prepared statement |
int acl::db_sqlite::sqlite3_step | ( | sqlite3_stmt * | stmt | ) |
计算 prepared statement
stmt | {sqlite3_stmt*} prepared statement |
|
virtual |
@override
实现了 acl::db_handle.
const char* acl::db_sqlite::version | ( | void | ) | const |
返回当前的 sqlite 的版本信息