本文整理汇总了C++中CppSQLite3Statement类的典型用法代码示例。如果您正苦于以下问题:C++ CppSQLite3Statement类的具体用法?C++ CppSQLite3Statement怎么用?C++ CppSQLite3Statement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CppSQLite3Statement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: int64toa
void CBrainMemory::SetSystemItem(int64 Item,AnsiString Info){
CppSQLite3Buffer SQL;
CppSQLite3Query Result;
char a[30],b[30];
int64toa(ROOM_SYSTEM,a);
int64toa(Item,b);
SQL.format("select b from \"%s\" where a = \"%s\";",a,b);
Result = BrainDB.execQuery(SQL);
bool Find = !Result.eof();
Result.finalize();
if(!Find){
SQL.format("insert into \"%s\" values (\"%s\", ?)",
a,
b);
}else{
SQL.format("update \"%s\" set b = ? where a = \"%s\";",
a,
b
);
}
CppSQLite3Statement State = BrainDB.compileStatement(SQL);
State.bind(1,Info.c_str()); //替换第一个问号
State.execDML();
}
示例2: sqlDeleteGroupInfoEntity
BOOL DatabaseModule_Impl::sqlDeleteGroupInfoEntity(IN const std::string& groupId)
{
try
{
CppSQLite3Statement stmt = m_pSqliteDB->compileStatement(deleteGroupInfoSql.c_str());
stmt.bind(1, groupId.c_str());
stmt.execDML();
}
catch (CppSQLite3Exception& sqliteException)
{
#ifdef _DEBUG
MessageBoxA(0, sqliteException.errorMessage(), "BD ERROR", MB_OK | MB_ICONHAND);
#endif
CString csErrMsg = util::stringToCString(sqliteException.errorMessage(), CP_UTF8);
LOG__(ERR, _T("delete failed,error msg:%s"), csErrMsg);
return FALSE;
}
catch (...)
{
LOG__(ERR, _T("db unknown exception"));
return FALSE;
}
return TRUE;
}
示例3: sqlInsertOrReplaceGroupInfoEntity
BOOL DatabaseModule_Impl::sqlInsertOrReplaceGroupInfoEntity(IN const module::GroupInfoEntity& groupInfo)
{
try
{
CppSQLite3Statement stmt = m_pSqliteDB->compileStatement(insertGroupInfoSql.c_str());
stmt.bind(1, groupInfo.gId.c_str());
stmt.bind(2, util::cStringToString(groupInfo.csName).c_str());
stmt.bind(3, util::cStringToString(groupInfo.desc).c_str());
stmt.bind(4, groupInfo.avatarUrl.c_str());
stmt.bind(5, groupInfo.creatorId.c_str());
stmt.bind(6, int(groupInfo.type));
stmt.bind(7, int(groupInfo.version));
stmt.bind(8, int(groupInfo.groupUpdated));
stmt.bind(9, int(groupInfo.shieldStatus));
std::string& strJson = _makeJsonForGroupMembers(groupInfo.groupMemeberList);
stmt.bind(10, strJson.c_str());
stmt.execDML();
}
catch (CppSQLite3Exception& sqliteException)
{
#ifdef _DEBUG
MessageBoxA(0, sqliteException.errorMessage(), "BD ERROR", MB_OK | MB_ICONHAND);
#endif
CString csErrMsg = util::stringToCString(sqliteException.errorMessage(), CP_UTF8);
LOG__(ERR, _T("insert failed,error msg:%s"), csErrMsg);
return FALSE;
}
catch (...)
{
LOG__(ERR, _T("db unknown exception"));
return FALSE;
}
return TRUE;
}
示例4: loadDatabaseInfo
void BaseDatabaseUnitImpl::runCreateStatements()
{
loadDatabaseInfo();
if (database_)
{
try
{
uint32_t version = databaseInfo_->latest_.version_;
for (auto it = databaseInfo_->latest_.tableList_.begin(); it != databaseInfo_->latest_.tableList_.end(); ++it)
{
CppSQLite3Statement statement = database_->compileStatement(it->statement_.c_str());
runTransaction(statement);
}
CppSQLite3Statement statement = database_->compileStatement(SQL_VERSION_TABLE_CREATE);
runTransaction(statement);
statement = database_->compileStatement(SQL_VERSION_TABLE_SET_VERSION);
statement.bind(1, VERSION_KEY);
statement.bind(2, (int)version);
runTransaction(statement);
runUpdateStatements();
}
catch (CppSQLite3Exception e)
{
LOG_ERR_R(DATABASE_MANAGER_LOG_TAG, _T("Failed to run create statements, error: %u"), e.errorCode());
LOG_ERR_D_A(DATABASE_MANAGER_LOG_TAG_A, "Message: %s", e.errorMessage());
}
}
}
示例5: compileStatement
int CppSQLite3DB::insertBlob(const CString& szSQL, const unsigned char *data, int dataLength)
{
CppSQLite3Statement statement = compileStatement(szSQL);
statement.bind(1, data, dataLength);
return statement.execDML();
}
示例6: CString
int CppSQLite3DB::updateBlob(const CString& szTableName, const CString& szFieldName, const unsigned char* data, int dataLength, const CString& szWhere)
{
CString sql = CString("update ") + szTableName + " set " + szFieldName + "=? where " + szWhere;
CppSQLite3Statement statement = compileStatement(sql);
statement.bind(1, data, dataLength);
return statement.execDML();
}
示例7: sqlUpdateRecentSessionInfoEntity
BOOL DatabaseModule_Impl::sqlUpdateRecentSessionInfoEntity(IN const module::SessionEntity& sessionInfo)
{
try
{
CppSQLite3Statement stmt = m_pSqliteDB->compileStatement(updateRecentSessionByIdSql.c_str());
stmt.bind(1, sessionInfo.sessionID.c_str());
stmt.bind(2, int(sessionInfo.sessionType));
stmt.bind(3, int(sessionInfo.updatedTime));
stmt.bind(4, int(sessionInfo.latestmsgId));
stmt.bind(5, sessionInfo.latestMsgContent.c_str());
stmt.bind(6, sessionInfo.latestMsgFromId.c_str());
stmt.bind(7, sessionInfo.sessionID.c_str());
int countUpdate = stmt.execDML();
if (0 == countUpdate)
{
return FALSE;
}
}
catch (CppSQLite3Exception& sqliteException)
{
#ifdef _DEBUG
MessageBoxA(0, sqliteException.errorMessage(), "BD ERROR", MB_OK | MB_ICONHAND);
#endif
CString csErrMsg = util::stringToCString(sqliteException.errorMessage(), CP_UTF8);
LOG__(ERR, _T("db failed,error msg:%s"), csErrMsg);
return FALSE;
}
catch (...)
{
LOG__(ERR, _T("db unknown exception"));
return FALSE;
}
return TRUE;
}
示例8: sqlGetGroupInfoByGId
BOOL DatabaseModule_Impl::sqlGetGroupInfoByGId(IN std::string& gId, OUT module::GroupInfoEntity& groupInfo)
{
try
{
CppSQLite3Statement stmt;
stmt = m_pSqliteDB->compileStatement(getGroupInfoByGIdSql.c_str());
stmt.bind(1, gId.c_str());
CppSQLite3Query query = stmt.execQuery();
if (!query.eof())
{
groupInfo.gId = gId;
groupInfo.csName = util::stringToCString(query.getStringField(2));
groupInfo.desc = util::stringToCString(query.getStringField(3));
groupInfo.avatarUrl = query.getStringField(4);
groupInfo.creatorId = query.getStringField(5);
groupInfo.type = query.getIntField(6);
groupInfo.version = query.getIntField(7);
groupInfo.groupUpdated = query.getIntField(8);
groupInfo.shieldStatus = query.getIntField(9);
_parseJsonForGroupMembers(query.getStringField(10), groupInfo.groupMemeberList);
}
else
{
return FALSE;
}
}
catch (CppSQLite3Exception& sqliteException)
{
#ifdef _DEBUG
MessageBoxA(0, sqliteException.errorMessage(), "BD ERROR", MB_OK | MB_ICONHAND);
#endif
CString csErrMsg = util::stringToCString(sqliteException.errorMessage(), CP_UTF8);
LOG__(ERR, _T("db failed,error msg:%s"),
csErrMsg);
return FALSE;
}
catch (...)
{
LOG__(ERR, _T("db unknown exception"));
return FALSE;
}
return TRUE;
}
示例9: _T
//##ModelId=474D30760272
bool CClip_ImportExport::ExportToSqliteDB(CppSQLite3DB &db)
{
bool bRet = false;
try
{
//Add to Main Table
m_Desc.Replace(_T("'"), _T("''"));
db.execDMLEx(_T("insert into Main values(NULL, %d, '%s');"), CURRENT_EXPORT_VERSION, m_Desc);
long lId = (long)db.lastRowId();
//Add to Data table
CClipFormat* pCF;
CppSQLite3Statement stmt = db.compileStatement(_T("insert into Data values (NULL, ?, ?, ?, ?);"));
for(int i = m_Formats.GetSize()-1; i >= 0 ; i--)
{
pCF = & m_Formats.ElementAt(i);
stmt.bind(1, lId);
stmt.bind(2, GetFormatName(pCF->m_cfType));
long lOriginalSize = GlobalSize(pCF->m_hgData);
stmt.bind(3, lOriginalSize);
const unsigned char *Data = (const unsigned char *)GlobalLock(pCF->m_hgData);
if(Data)
{
//First compress the data
long lZippedSize = compressBound(lOriginalSize);
Bytef *pZipped = new Bytef[lZippedSize];
if(pZipped)
{
int nZipReturn = compress(pZipped, (uLongf *)&lZippedSize, (const Bytef *)Data, lOriginalSize);
if(nZipReturn == Z_OK)
{
stmt.bind(4, pZipped, lZippedSize);
}
delete []pZipped;
pZipped = NULL;
}
}
GlobalUnlock(pCF->m_hgData);
stmt.execDML();
stmt.reset();
m_Formats.RemoveAt(i);
}
bRet = true;
}
CATCH_SQLITE_EXCEPTION_AND_RETURN(false)
return bRet;
}
示例10: sqlGetRecentSessionInfoByGId
BOOL DatabaseModule_Impl::sqlGetRecentSessionInfoByGId(IN std::string& sId, OUT module::SessionEntity& sessionInfo)
{
try
{
CppSQLite3Statement stmt;
stmt = m_pSqliteDB->compileStatement(getRecentSessionByIdSql.c_str());
stmt.bind(1, sId.c_str());
CppSQLite3Query query = stmt.execQuery();
if (!query.eof())
{
sessionInfo.sessionID = sId;
sessionInfo.sessionType = query.getIntField(2);
sessionInfo.updatedTime = query.getIntField(3);
sessionInfo.latestmsgId = query.getIntField(4);
sessionInfo.latestMsgContent = query.getStringField(5);
sessionInfo.latestMsgFromId = query.getStringField(6);
}
else
{
return FALSE;
}
}
catch (CppSQLite3Exception& sqliteException)
{
#ifdef _DEBUG
MessageBoxA(0, sqliteException.errorMessage(), "BD ERROR", MB_OK | MB_ICONHAND);
#endif
CString csErrMsg = util::stringToCString(sqliteException.errorMessage(), CP_UTF8);
LOG__(ERR, _T("db failed,error msg:%s"),
csErrMsg);
return FALSE;
}
catch (...)
{
LOG__(ERR, _T("db unknown exception"));
return FALSE;
}
return TRUE;
}
示例11: sqlUpdateGroupInfoEntity
BOOL DatabaseModule_Impl::sqlUpdateGroupInfoEntity(std::string& sId, IN const module::GroupInfoEntity& groupInfo)
{
try
{
//"update groupinfo set name=?,desc=?,avatarUrl=?,creatorId=?,type=?,version=?,lastUpdateTime=?,shieldStatus=?,memberlist=? where groupId=?";
CppSQLite3Statement stmt = m_pSqliteDB->compileStatement(updateGroupInfoBySIdSql.c_str());
stmt.bind(1, util::cStringToString(groupInfo.csName).c_str());
stmt.bind(2, util::cStringToString(groupInfo.desc).c_str());
stmt.bind(3, groupInfo.avatarUrl.c_str());
stmt.bind(4, groupInfo.creatorId.c_str());
stmt.bind(5, int(groupInfo.type));
stmt.bind(6, int(groupInfo.version));
stmt.bind(7, int(groupInfo.groupUpdated));
stmt.bind(8, int(groupInfo.shieldStatus));
std::string& strJson = _makeJsonForGroupMembers(groupInfo.groupMemeberList);
stmt.bind(9, strJson.c_str());
stmt.bind(9, groupInfo.gId.c_str());
int countUpdate = stmt.execDML();
if (0 == countUpdate)
{
LOG__(ERR, _T("db update failed:%s"), util::stringToCString(groupInfo.gId));
return FALSE;
}
}
catch (CppSQLite3Exception& sqliteException)
{
#ifdef _DEBUG
MessageBoxA(0, sqliteException.errorMessage(), "BD ERROR", MB_OK | MB_ICONHAND);
#endif
CString csErrMsg = util::stringToCString(sqliteException.errorMessage(), CP_UTF8);
LOG__(ERR, _T("db failed,error msg:%s"), csErrMsg);
return FALSE;
}
catch (...)
{
return FALSE;
}
return TRUE;
}
示例12: sqlGetFileTransferHistory
BOOL DatabaseModule_Impl::sqlGetFileTransferHistory(OUT std::vector<TransferFileEntity>& fileList)
{
try
{
CppSQLite3Statement stmt;
stmt = m_pSqliteDB->compileStatement(getFileTransferHistoryBySIdSql.c_str());
stmt.bind(1, 20);
CppSQLite3Query query = stmt.execQuery();
while (!query.eof())
{
TransferFileEntity fileInfo;
fileInfo.sTaskID = query.getStringField(1);
fileInfo.sFromID = query.getStringField(2);
fileInfo.sFileName = query.getStringField(3);
CString strSavePath = util::stringToCString(query.getStringField(7));
fileInfo.setSaveFilePath(strSavePath);
fileInfo.nFileSize = query.getIntField(8);
fileInfo.time = query.getIntField(9);
fileList.push_back(fileInfo);
query.nextRow();
}
}
catch (CppSQLite3Exception& sqliteException)
{
#ifdef _DEBUG
MessageBoxA(0, sqliteException.errorMessage(), "BD ERROR", MB_OK | MB_ICONHAND);
#endif
CString csErrMsg = util::stringToCString(sqliteException.errorMessage(), CP_UTF8);
LOG__(ERR, _T("db failed,error msg:%s"),
csErrMsg);
return FALSE;
}
catch (...)
{
return FALSE;
}
return TRUE;
}
示例13: sqlGetAllRecentSessionInfo
BOOL DatabaseModule_Impl::sqlGetAllRecentSessionInfo(OUT std::vector<module::SessionEntity>& sessionList)
{
try
{
CppSQLite3Statement stmt;
stmt = m_pSqliteDB->compileStatement(getAllRecentSessionSql.c_str());
CppSQLite3Query query = stmt.execQuery();
while (!query.eof())
{
module::SessionEntity sessionInfo;
sessionInfo.sessionID = query.getStringField(1);;
sessionInfo.sessionType = query.getIntField(2);
sessionInfo.updatedTime = query.getIntField(3);
sessionInfo.latestmsgId = query.getIntField(4);
sessionInfo.latestMsgContent = query.getStringField(5);
sessionInfo.latestMsgFromId = query.getStringField(6);
sessionList.push_back(sessionInfo);
query.nextRow();
}
}
catch (CppSQLite3Exception& sqliteException)
{
#ifdef _DEBUG
MessageBoxA(0, sqliteException.errorMessage(), "BD ERROR", MB_OK | MB_ICONHAND);
#endif
CString csErrMsg = util::stringToCString(sqliteException.errorMessage(), CP_UTF8);
LOG__(ERR, _T("select failed,error msg:%s"),
csErrMsg);
return FALSE;
}
catch (...)
{
LOG__(ERR, _T("db unknown exception"));
return FALSE;
}
return TRUE;
}
示例14: getDatabaseVersion
uint32_t BaseDatabaseUnitImpl::getDatabaseVersion()
{
if (database_)
{
try
{
CppSQLite3Statement statement = database_->compileStatement(SQL_VERSION_TABLE_GET_VERSION);
statement.bind(1, VERSION_KEY);
CppSQLite3Query result = statement.execQuery();
if (!result.eof())
{
return (uint32_t)result.getIntField("version");
}
}
catch (CppSQLite3Exception e)
{
LOG_ERR_R(DATABASE_MANAGER_LOG_TAG, _T("Failed to get database version, error: %u"), e.errorCode());
LOG_ERR_D_A(DATABASE_MANAGER_LOG_TAG_A, "Message: %s", e.errorMessage());
}
}
return 0;
}
示例15: LOG__
BOOL DatabaseModule_Impl::sqlInsertFileTransferHistory(IN TransferFileEntity& fileInfo)
{
if (fileInfo.nClientMode == IM::BaseDefine::ClientFileRole::CLIENT_OFFLINE_UPLOAD
|| fileInfo.nClientMode == IM::BaseDefine::ClientFileRole::CLIENT_REALTIME_SENDER)
{
LOG__(DEBG, _T("fileInfo.nClientMode not fixed"));
return FALSE;
}
try
{
CppSQLite3Statement stmt = m_pSqliteDB->compileStatement(insertFileTransferHistorySql.c_str());
stmt.bind(1, fileInfo.sTaskID.c_str());
stmt.bind(2, fileInfo.sFromID.c_str());
std::string filename = util::cStringToString(fileInfo.getRealFileName());
stmt.bind(3, filename.c_str());
std::string savePath = util::cStringToString(fileInfo.getSaveFilePath());
stmt.bind(7, savePath.c_str());
stmt.bind(8, (Int32)fileInfo.nFileSize);
stmt.bind(9, time(0));
stmt.execDML();
}
catch (CppSQLite3Exception& sqliteException)
{
#ifdef _DEBUG
MessageBoxA(0, sqliteException.errorMessage(), "BD ERROR", MB_OK | MB_ICONHAND);
#endif
CString csErrMsg = util::stringToCString(sqliteException.errorMessage(), CP_UTF8);
LOG__(ERR, _T("failed,error msg:%s"), csErrMsg);
return FALSE;
}
catch (...)
{
LOG__(ERR, _T("unknown exception"));
return FALSE;
}
return TRUE;
}