Skip to content

Commit

Permalink
modify db module(including mysql, sqlite) for using db more convinien…
Browse files Browse the repository at this point in the history
…tly; add mysql_pool sample
  • Loading branch information
ubuntu14 committed Aug 2, 2015
1 parent 5a28483 commit a37ba6e
Show file tree
Hide file tree
Showing 47 changed files with 2,240 additions and 144 deletions.
16 changes: 16 additions & 0 deletions acl_cpp_vc2008.sln
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,13 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "redis_geo", "lib_acl_cpp\sa
{FE724EF7-3763-4E78-BDF5-BCBC075719FD} = {FE724EF7-3763-4E78-BDF5-BCBC075719FD}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mysql_pool", "lib_acl_cpp\samples\db\mysql_pool\mysql_pool_2008.vcproj", "{CDB5750C-9937-47BB-B138-63E2318CEF52}"
ProjectSection(ProjectDependencies) = postProject
{64BF4D83-53BB-4045-8522-9FF9F73B14D4} = {64BF4D83-53BB-4045-8522-9FF9F73B14D4}
{B40213C2-507C-4C7F-A6E1-B850C9BDC27B} = {B40213C2-507C-4C7F-A6E1-B850C9BDC27B}
{FE724EF7-3763-4E78-BDF5-BCBC075719FD} = {FE724EF7-3763-4E78-BDF5-BCBC075719FD}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Expand Down Expand Up @@ -1313,6 +1320,14 @@ Global
{2147D0CD-57C8-4C50-BBA8-71EF03B7C2AA}.Release|Win32.Build.0 = Release|Win32
{2147D0CD-57C8-4C50-BBA8-71EF03B7C2AA}.Releasedll|Win32.ActiveCfg = Releasedll|Win32
{2147D0CD-57C8-4C50-BBA8-71EF03B7C2AA}.Releasedll|Win32.Build.0 = Releasedll|Win32
{CDB5750C-9937-47BB-B138-63E2318CEF52}.Debug|Win32.ActiveCfg = Debug|Win32
{CDB5750C-9937-47BB-B138-63E2318CEF52}.Debug|Win32.Build.0 = Debug|Win32
{CDB5750C-9937-47BB-B138-63E2318CEF52}.DebugDll|Win32.ActiveCfg = DebugDll|Win32
{CDB5750C-9937-47BB-B138-63E2318CEF52}.DebugDll|Win32.Build.0 = DebugDll|Win32
{CDB5750C-9937-47BB-B138-63E2318CEF52}.Release|Win32.ActiveCfg = Release|Win32
{CDB5750C-9937-47BB-B138-63E2318CEF52}.Release|Win32.Build.0 = Release|Win32
{CDB5750C-9937-47BB-B138-63E2318CEF52}.Releasedll|Win32.ActiveCfg = Releasedll|Win32
{CDB5750C-9937-47BB-B138-63E2318CEF52}.Releasedll|Win32.Build.0 = Releasedll|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -1378,6 +1393,7 @@ Global
{DC7E75E5-FE42-4529-9D9A-19D240B8727B} = {9FE233BA-6510-4A21-9CB4-C2FF448506A3}
{DF860891-7D7E-473C-A07C-B0959D91C298} = {9FE233BA-6510-4A21-9CB4-C2FF448506A3}
{10B61B37-2242-426E-A56A-8AC6D4FA91FA} = {9FE233BA-6510-4A21-9CB4-C2FF448506A3}
{CDB5750C-9937-47BB-B138-63E2318CEF52} = {9FE233BA-6510-4A21-9CB4-C2FF448506A3}
{7680672C-4C9B-4BE8-8BAE-BB23B951AAA0} = {462CDA64-00AD-4468-B0CD-A24D8897BE04}
{7DA0AC89-62E4-4D02-9BC5-C32E6846E168} = {462CDA64-00AD-4468-B0CD-A24D8897BE04}
{41FA5224-3315-4CDA-9C44-19085049F179} = {462CDA64-00AD-4468-B0CD-A24D8897BE04}
Expand Down
18 changes: 18 additions & 0 deletions acl_cpp_vc2010.sln
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,13 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "redis_geo_vc2010", "lib_acl
{FE724EF7-3763-4E78-BDF5-BCBC075719FD} = {FE724EF7-3763-4E78-BDF5-BCBC075719FD}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mysql_pool", "lib_acl_cpp\samples\db\mysql_pool\mysql_pool.vcxproj", "{7C56C0AF-4311-4D5B-BD32-DC240B4752B1}"
ProjectSection(ProjectDependencies) = postProject
{6EC1F44E-6A6A-48E9-B699-D7E89B63C8DC} = {6EC1F44E-6A6A-48E9-B699-D7E89B63C8DC}
{B40213C2-507C-4C7F-A6E1-B850C9BDC27B} = {B40213C2-507C-4C7F-A6E1-B850C9BDC27B}
{FE724EF7-3763-4E78-BDF5-BCBC075719FD} = {FE724EF7-3763-4E78-BDF5-BCBC075719FD}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Expand Down Expand Up @@ -900,6 +907,16 @@ Global
{50A37701-CDC8-477E-8B7F-711FB0A90844}.Releasedll|Win32.Build.0 = Releasedll|Win32
{50A37701-CDC8-477E-8B7F-711FB0A90844}.Template|Win32.ActiveCfg = Release|Win32
{50A37701-CDC8-477E-8B7F-711FB0A90844}.Template|Win32.Build.0 = Release|Win32
{7C56C0AF-4311-4D5B-BD32-DC240B4752B1}.Debug|Win32.ActiveCfg = Debug|Win32
{7C56C0AF-4311-4D5B-BD32-DC240B4752B1}.Debug|Win32.Build.0 = Debug|Win32
{7C56C0AF-4311-4D5B-BD32-DC240B4752B1}.DebugDll|Win32.ActiveCfg = DebugDll|Win32
{7C56C0AF-4311-4D5B-BD32-DC240B4752B1}.DebugDll|Win32.Build.0 = DebugDll|Win32
{7C56C0AF-4311-4D5B-BD32-DC240B4752B1}.Release|Win32.ActiveCfg = Release|Win32
{7C56C0AF-4311-4D5B-BD32-DC240B4752B1}.Release|Win32.Build.0 = Release|Win32
{7C56C0AF-4311-4D5B-BD32-DC240B4752B1}.Releasedll|Win32.ActiveCfg = Releasedll|Win32
{7C56C0AF-4311-4D5B-BD32-DC240B4752B1}.Releasedll|Win32.Build.0 = Releasedll|Win32
{7C56C0AF-4311-4D5B-BD32-DC240B4752B1}.Template|Win32.ActiveCfg = Release|Win32
{7C56C0AF-4311-4D5B-BD32-DC240B4752B1}.Template|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -940,6 +957,7 @@ Global
{7C9D5B5D-BA0A-4824-9965-3411E2B8A613} = {A5DD26EC-A86B-4FDE-9755-126D32CC5ECA}
{3311B16C-D9A4-4945-9C76-DF89BF1A5B66} = {40474FC9-B138-46A7-BC32-338948234E38}
{68F0F844-7072-47C5-BE72-221BE3CACFC4} = {40474FC9-B138-46A7-BC32-338948234E38}
{7C56C0AF-4311-4D5B-BD32-DC240B4752B1} = {40474FC9-B138-46A7-BC32-338948234E38}
{2DABFAD1-114B-4F96-9185-DC0C56A3662D} = {E13E15EC-19A7-4AF4-A147-38EA5CEDD3CD}
{A1B397E8-0699-4912-A6F3-693F468CA0ED} = {E13E15EC-19A7-4AF4-A147-38EA5CEDD3CD}
{55AF6A85-F829-47DC-A324-32837E0A7C9E} = {7B001BDA-0EFF-4EE0-89E7-C0EECE8955A9}
Expand Down
43 changes: 43 additions & 0 deletions acl_cpp_vc2012.sln
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "query", "lib_acl_cpp\sample
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mysql_query", "lib_acl_cpp\samples\db\mysql_query\mysql_query_vc2012.vcxproj", "{2495A6D4-777F-48BF-99C0-702E4A11FD23}"
ProjectSection(ProjectDependencies) = postProject
{6EC1F44E-6A6A-48E9-B699-D7E89B63C8DC} = {6EC1F44E-6A6A-48E9-B699-D7E89B63C8DC}
{B40213C2-507C-4C7F-A6E1-B850C9BDC27B} = {B40213C2-507C-4C7F-A6E1-B850C9BDC27B}
{FE724EF7-3763-4E78-BDF5-BCBC075719FD} = {FE724EF7-3763-4E78-BDF5-BCBC075719FD}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "blank_line", "lib_acl_cpp\samples\string\blank_line\blank_line_vc2012.vcxproj", "{DEDE0B8A-35C5-4674-A10A-BF6544F6A885}"
ProjectSection(ProjectDependencies) = postProject
Expand Down Expand Up @@ -542,6 +547,13 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "redis_geo", "lib_acl_cpp\sa
{FE724EF7-3763-4E78-BDF5-BCBC075719FD} = {FE724EF7-3763-4E78-BDF5-BCBC075719FD}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mysql_pool", "lib_acl_cpp\samples\db\mysql_pool\mysql_pool_vc2012.vcxproj", "{EB430C52-31E4-4018-AD8A-8F56ADAD586A}"
ProjectSection(ProjectDependencies) = postProject
{6EC1F44E-6A6A-48E9-B699-D7E89B63C8DC} = {6EC1F44E-6A6A-48E9-B699-D7E89B63C8DC}
{B40213C2-507C-4C7F-A6E1-B850C9BDC27B} = {B40213C2-507C-4C7F-A6E1-B850C9BDC27B}
{FE724EF7-3763-4E78-BDF5-BCBC075719FD} = {FE724EF7-3763-4E78-BDF5-BCBC075719FD}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Mixed Platforms = Debug|Mixed Platforms
Expand Down Expand Up @@ -2631,6 +2643,36 @@ Global
{AE10B13D-774D-49A5-9066-E90F124BA99C}.Template|Win32.Build.0 = DebugDll|Win32
{AE10B13D-774D-49A5-9066-E90F124BA99C}.Template|x64.ActiveCfg = DebugDll|x64
{AE10B13D-774D-49A5-9066-E90F124BA99C}.Template|x64.Build.0 = DebugDll|x64
{EB430C52-31E4-4018-AD8A-8F56ADAD586A}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{EB430C52-31E4-4018-AD8A-8F56ADAD586A}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{EB430C52-31E4-4018-AD8A-8F56ADAD586A}.Debug|Win32.ActiveCfg = Debug|Win32
{EB430C52-31E4-4018-AD8A-8F56ADAD586A}.Debug|Win32.Build.0 = Debug|Win32
{EB430C52-31E4-4018-AD8A-8F56ADAD586A}.Debug|x64.ActiveCfg = Debug|x64
{EB430C52-31E4-4018-AD8A-8F56ADAD586A}.Debug|x64.Build.0 = Debug|x64
{EB430C52-31E4-4018-AD8A-8F56ADAD586A}.DebugDll|Mixed Platforms.ActiveCfg = DebugDll|Win32
{EB430C52-31E4-4018-AD8A-8F56ADAD586A}.DebugDll|Mixed Platforms.Build.0 = DebugDll|Win32
{EB430C52-31E4-4018-AD8A-8F56ADAD586A}.DebugDll|Win32.ActiveCfg = DebugDll|Win32
{EB430C52-31E4-4018-AD8A-8F56ADAD586A}.DebugDll|Win32.Build.0 = DebugDll|Win32
{EB430C52-31E4-4018-AD8A-8F56ADAD586A}.DebugDll|x64.ActiveCfg = DebugDll|x64
{EB430C52-31E4-4018-AD8A-8F56ADAD586A}.DebugDll|x64.Build.0 = DebugDll|x64
{EB430C52-31E4-4018-AD8A-8F56ADAD586A}.Release|Mixed Platforms.ActiveCfg = Release|Win32
{EB430C52-31E4-4018-AD8A-8F56ADAD586A}.Release|Mixed Platforms.Build.0 = Release|Win32
{EB430C52-31E4-4018-AD8A-8F56ADAD586A}.Release|Win32.ActiveCfg = Release|Win32
{EB430C52-31E4-4018-AD8A-8F56ADAD586A}.Release|Win32.Build.0 = Release|Win32
{EB430C52-31E4-4018-AD8A-8F56ADAD586A}.Release|x64.ActiveCfg = Release|x64
{EB430C52-31E4-4018-AD8A-8F56ADAD586A}.Release|x64.Build.0 = Release|x64
{EB430C52-31E4-4018-AD8A-8F56ADAD586A}.Releasedll|Mixed Platforms.ActiveCfg = Releasedll|Win32
{EB430C52-31E4-4018-AD8A-8F56ADAD586A}.Releasedll|Mixed Platforms.Build.0 = Releasedll|Win32
{EB430C52-31E4-4018-AD8A-8F56ADAD586A}.Releasedll|Win32.ActiveCfg = Releasedll|Win32
{EB430C52-31E4-4018-AD8A-8F56ADAD586A}.Releasedll|Win32.Build.0 = Releasedll|Win32
{EB430C52-31E4-4018-AD8A-8F56ADAD586A}.Releasedll|x64.ActiveCfg = Releasedll|x64
{EB430C52-31E4-4018-AD8A-8F56ADAD586A}.Releasedll|x64.Build.0 = Releasedll|x64
{EB430C52-31E4-4018-AD8A-8F56ADAD586A}.Template|Mixed Platforms.ActiveCfg = DebugDll|Win32
{EB430C52-31E4-4018-AD8A-8F56ADAD586A}.Template|Mixed Platforms.Build.0 = DebugDll|Win32
{EB430C52-31E4-4018-AD8A-8F56ADAD586A}.Template|Win32.ActiveCfg = DebugDll|Win32
{EB430C52-31E4-4018-AD8A-8F56ADAD586A}.Template|Win32.Build.0 = DebugDll|Win32
{EB430C52-31E4-4018-AD8A-8F56ADAD586A}.Template|x64.ActiveCfg = DebugDll|x64
{EB430C52-31E4-4018-AD8A-8F56ADAD586A}.Template|x64.Build.0 = DebugDll|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -2696,6 +2738,7 @@ Global
{5F75216D-8263-4F6F-9390-76E7AC129AEE} = {3A25DC67-2832-4912-8FD5-66E499E38F11}
{D1F030D1-36F7-4440-9801-42E31E767A52} = {FB676B5A-D82C-45CB-9E1F-F3793419DDA9}
{2495A6D4-777F-48BF-99C0-702E4A11FD23} = {FB676B5A-D82C-45CB-9E1F-F3793419DDA9}
{EB430C52-31E4-4018-AD8A-8F56ADAD586A} = {FB676B5A-D82C-45CB-9E1F-F3793419DDA9}
{640ABB35-FBD3-4D34-A382-9ED8CF3FCE34} = {267F658E-44AF-4080-8577-EFCE99A5E030}
{4B58485B-D846-4485-9C5E-7F2304D71701} = {267F658E-44AF-4080-8577-EFCE99A5E030}
{9073FA9F-26A1-482C-91D0-876434C3E4EB} = {267F658E-44AF-4080-8577-EFCE99A5E030}
Expand Down
1 change: 1 addition & 0 deletions dist/lib/freebsd/keep.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
keepme
1 change: 1 addition & 0 deletions dist/lib/linux32/keep.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
keepme
1 change: 1 addition & 0 deletions dist/lib/linux64/keep.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
keepme
1 change: 1 addition & 0 deletions dist/lib/macos/keep.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
keepme
1 change: 1 addition & 0 deletions dist/lib/solaris/keep.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
keepme
1 change: 1 addition & 0 deletions lib/freebsd/keep.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
keep
1 change: 1 addition & 0 deletions lib/linux32/keep.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
keep
1 change: 1 addition & 0 deletions lib/linux64/keep.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
keep
1 change: 1 addition & 0 deletions lib/macos/keep.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
keep
1 change: 1 addition & 0 deletions lib/solaris/keep.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
keep
1 change: 1 addition & 0 deletions lib/win32/keep.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
keep
1 change: 1 addition & 0 deletions lib/win64/keep.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
keep
3 changes: 2 additions & 1 deletion lib_acl_cpp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ CFLAGS = -c -g -W \
-D_POSIX_PTHREAD_SEMANTICS \
-Wno-long-long \
-Wformat \
-DHAS_POLARSSL
-DHAS_POLARSSL \
-DHAS_MYSQL_DLL
#-DUSE_DYNAMIC
# -Wcast-align
#-Wcast-qual
Expand Down
17 changes: 17 additions & 0 deletions lib_acl_cpp/changes.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
�޸���ʷ�б���

------------------------------------------------------------------------
335) 2015.8.2
335.1) feature: db_handle/db_mysql/db_sqlite �����ṩ�˾�̬�����������ö�̬�⶯̬
���ص�ȫ·��
335.2) feature: mysql ģ�鹦����Ĭ�ϱ���ʱ������� lib_acl_cpp ���У�
�� db_mysql ģ��Ĭ�ϲ��ö�̬���ط�ʽ
335.3) samples/db/mysql_query: ������ʾ������
335.4) samples: ������ʾ�� samples/db/mysql_pool���������Զ��̻߳����µ����ݿ�
���ӳز���

334) 2015.8.1
334.1) feature: ��Ա�׼�����������������������stdin_stream, stdout_stream
334.2) sample: db/mysql_query ��������

333) 2015.7.31
333.1) feature: HttpServlet ���еķ��� doRun �ڲ�����Ӧ�ͻ�������ʱ��������
���ݿͻ��˵�����ͷ�ֶ�(Connection) �Զ�������Ӧͷ�е� Connection ͷ�ֶ�

332) 2015.7.30
332.1) bugfix: redis_command::redirect() �����ڵ� cluster->peek() ���� NULL
ʱӦ��ֱ�ӷ��� NULL
Expand Down
15 changes: 13 additions & 2 deletions lib_acl_cpp/include/acl_cpp/db/db_handle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,10 @@ class ACL_CPP_API db_handle

/**
* 纯虚接口,子类必须实现此接口用于打开数据库
* @param local_charset {const char*} 本地字符集(GBK, UTF8, ...)
* @param local_charset {const char*} 本地字符集(gbk, utf8, ...)
* @return {bool} 打开是否成功
*/
virtual bool open(const char* local_charset = "GBK") = 0;
virtual bool open(const char* local_charset = "utf8") = 0;

/**
* 数据库是否已经打开了
Expand Down Expand Up @@ -418,6 +418,17 @@ class ACL_CPP_API db_handle
return when_;
}

/**
* 当采用动态加载方式加载动态库时,可以使用此函数设置动态库的加载全路径
*/
static void set_loadpath(const char* path);

/**
* 当设置了动态库的动态加载全路径时,可以通过本函数获得动态库加载全路径
* @return {const char*} 当未设置时则返回 NULL
*/
static const char* get_loadpath();

protected:
// 临时结果对象
db_rows* result_;
Expand Down
24 changes: 12 additions & 12 deletions lib_acl_cpp/include/acl_cpp/db/db_mysql.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,67 +45,67 @@ class ACL_CPP_API db_mysql : public db_handle
* 返回数据库的类型描述
* @return {const char*}
*/
virtual const char* dbtype() const;
const char* dbtype() const;

/**
* 获得上次数据库操作的出错错误号
* @return {int}
*/
virtual int get_errno() const;
int get_errno() const;

/**
* 获得上次数据库操作的出错错描述
* @return {const char*}
*/
virtual const char* get_error() const;
const char* get_error() const;

/**
* 基类 db_handle 的纯虚接口
* @param local_charset {const char*} 本地字符集
* @param local_charset {const char*} 本地字符集(gbk, utf8, ...)
* @return {bool} 打开是否成功
*/
virtual bool open(const char* local_charset = "GBK");
bool open(const char* local_charset = "utf8");

/**
* 基类 db_handle 的纯虚接口,数据库是否已经打开了
* @return {bool} 返回 true 表明数据库已经打开了
*/
virtual bool is_opened() const;
bool is_opened() const;

/**
* 基类 db_handle 的纯虚接口
* @return {bool} 关闭是否成功
*/
virtual bool close(void);
bool close(void);

/**
* 基类 db_handle 的纯虚接口,子类必须实现此接口用于判断数据表是否存在
* @return {bool} 是否存在
*/
virtual bool tbl_exists(const char* tbl_name);
bool tbl_exists(const char* tbl_name);

/**
* 基类 db_handle 的纯虚接口
* @param sql {const char*} 标准的 SQL 语句,非空,并且一定得要注册该
* SQL 语句必须经过转义处理,以防止 SQL 注入攻击
* @return {bool} 执行是否成功
*/
virtual bool sql_select(const char* sql);
bool sql_select(const char* sql);

/**
* 基类 db_handle 的纯虚接口
* @param sql {const char*} 标准的 SQL 语句,非空,并且一定得要注册该
* SQL 语句必须经过转义处理,以防止 SQL 注入攻击
* @return {bool} 执行是否成功
*/
virtual bool sql_update(const char* sql);
bool sql_update(const char* sql);

/**
* 基类 db_handle 的纯虚接口:上次 sql 操作影响的记录行数
* @return {int} 影响的行数,-1 表示出错
*/
virtual int affect_count() const;
protected:
int affect_count() const;

private:
char* dbaddr_; // 数据库监听地址
char* dbname_; // 数据库名
Expand Down
23 changes: 12 additions & 11 deletions lib_acl_cpp/include/acl_cpp/db/db_sqlite.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,66 +71,67 @@ class ACL_CPP_API db_sqlite : public db_handle
* 返回数据库的类型描述
* @return {const char*}
*/
virtual const char* dbtype() const;
const char* dbtype() const;

/**
* 获得上次数据库操作的出错错误号
* @return {int}
*/
virtual int get_errno() const;
int get_errno() const;

/**
* 获得上次数据库操作的出错错描述
* @return {const char*}
*/
virtual const char* get_error() const;
const char* get_error() const;

/**
* 基类 db_handle 的纯虚接口
* @param local_charset {const char*} 本地字符集
* @param local_charset {const char*} 本地字符集(gbk, utf-8, ...)
* @return {bool} 打开是否成功
*/
virtual bool open(const char* local_charset = "GBK");
bool open(const char* local_charset = "utf-8");

/**
* 基类 db_handle 的纯虚接口,数据库是否已经打开了
* @return {bool} 返回 true 表明数据库已经打开了
*/
virtual bool is_opened() const;
bool is_opened() const;

/**
* 基类 db_handle 的纯虚接口
* @return {bool} 关闭是否成功
*/
virtual bool close(void);
bool close(void);

/**
* 基类 db_handle 的纯虚接口,子类必须实现此接口用于判断数据表是否存在
* @return {bool} 是否存在
*/
virtual bool tbl_exists(const char* tbl_name);
bool tbl_exists(const char* tbl_name);

/**
* 基类 db_handle 的纯虚接口
* @param sql {const char*} 标准的 SQL 语句,非空,并且一定得要注册该
* SQL 语句必须经过转义处理,以防止 SQL 注入攻击
* @return {bool} 执行是否成功
*/
virtual bool sql_select(const char* sql);
bool sql_select(const char* sql);

/**
* 基类 db_handle 的纯虚接口
* @param sql {const char*} 标准的 SQL 语句,非空,并且一定得要注册该
* SQL 语句必须经过转义处理,以防止 SQL 注入攻击
* @return {bool} 执行是否成功
*/
virtual bool sql_update(const char* sql);
bool sql_update(const char* sql);

/**
* 基类 db_handle 的纯虚接口:上次 sql 操作影响的记录行数
* @return {int} 影响的行数,-1 表示出错
*/
virtual int affect_count() const;
int affect_count() const;

private:
// sqlite 引擎
sqlite3* db_;
Expand Down
Loading

0 comments on commit a37ba6e

Please sign in to comment.