#include"sqlliteConnect.h"
CSqlConnection::CSqlConnection()
{
m_pSqliteDBHandle = new CSqlite3();
}
CSqlConnection::~CSqlConnection()
{
CloseDB();
}
int CSqlConnection::ConnectionDB(const char* pcFileName, int nMemberFlag)
{
int nRet = 0;
if (NULL == pcFileName || NULL == m_pSqliteDBHandle)
{
return -1;
}
lock_guard(m_lockMutex);
nRet = m_pSqliteDBHandle->OpenDB(pcFileName, nMemberFlag);
return nRet;
}
int CSqlConnection::AttachDB(const char* pcFileName, const char* pcAliName)
{
int nRet = 0;
if (NULL == pcFileName || NULL == pcAliName || NULL == m_pSqliteDBHandle)
{
return -1;
}
lock_guard(m_lockMutex);
nRet = m_pSqliteDBHandle->AttachDB(pcFileName, pcAliName);
return nRet;
}
int CSqlConnection::CloseDB()
{
int nRet = 0;
if (NULL == m_pSqliteDBHandle)
{
return -1;
}
lock_guard(m_lockMutex);
nRet = m_pSqliteDBHandle->CloseDB();
return nRet;
}
int CSqlConnection::InitMemberDB()
{
int nRet = 0;
nRet = InitDropTable();
if (0 != nRet)
{
return nRet;
}
nRet = InitCreateTable();
if (0 != nRet)
{
return nRet;
}
nRet = InitCreateIndex();
if (0 != nRet)
{
return nRet;
}
nRet = InitCreateTrigger();
return nRet;
}
CSqlite3* CSqlConnection::GeetFreeConn()
{
return m_pSqliteDBHandle;
}
int CSqlConnection::QueryValueDB(const char* pcSql, int& nValue)
{
CSqlite3* pConn = NULL;
int nValueTemp = 0;
int nRet = 0;
if (NULL == pcSql