1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- #ifndef __SQLITE3INTERFACE_H_
- #define __SQLITE3INTERFACE_H_
- /************************************************************************/
- /*
- 类名: CSQLiter3Interface
- 描述: sqlite3数据库操作
- */
- /************************************************************************/
- #include <string>
- #ifndef _UNICODE
- typedef std::string TString;
- #else
- typedef wstring TString;
- #endif
- struct sqlite3;
- // 创建表,注意:SQLite3每条SQL语句结束时需要加上分号;
- #define CREATE_DB_TBL_ "create table remoteinfo(\
- [domain] text not null,\
- [shopname] text not null,\
- [ipaddr] text not null,\
- [pcname] text not null,\
- [sharedir] text not null,\
- PRIMARY KEY([domain]));"
- //////////////////////////////////////////////////////////////////////////
- // 唯一的应用程序对象
- typedef struct _STRemoteInfo_
- {
- int bInUse;
- TCHAR szBranch[MAX_PATH];
- TCHAR szIP[MAX_PATH];
- TCHAR szDoMain[MAX_PATH];
- }STRemoteInfo,*pSTRemoteInfo;
- class CSQLiter3Interface
- {
- CSQLiter3Interface();
- public:
-
- ~CSQLiter3Interface();
- static CSQLiter3Interface* GetInstance()
- {
- static CSQLiter3Interface db;
- return &db;
- }
- //打开
- int OpenSQLite3DB(const char* pDBPath);
- //创建表
- int CreateTabel(const char* pSql, CString& strError);
- //执行
- int Exec(const char* pSql, CString& strError);
- //错误消息
- const char* Get_ErrMsg();
- //查询
- int Select(const char* pTableName, const char* pFields, const char* pLimit, std::vector<TString>& vValues, CString& strError);
- //插入
- int Insert(const char* pTableName, const char* pFields, const char* pValues, CString& strError);
- //删除
- int Delete(const char* pTableName, const char* pLimit, CString& strError);
- //关闭
- int Close();
- private:
- sqlite3* m_pSqli3db;
- };
- #endif
|