Files
mir_server/sdk/utils/SqlHelper.h

77 lines
1.9 KiB
C
Raw Normal View History

2025-01-09 17:45:40 +08:00
#pragma once
/*
*
* Sql封装类线SQL查询加锁后没有释放锁线
* 使
CSqlHelper sqlHelper(&m_SQLConn)
sqlHelper.Exec(sQueryActorData, ...)
* CSqlHelper内部有个变量
* SQL::ResetQuery()CSqlHelper类的m_bNeedReset
* db查询命令Reset
*
* // 执行SQL命令1
* CSqlHelper sqlHelper(&m_SQLConn)
* sqlHelper.Exec(sDBCmd1);
* // 这里需要手动重置
* sqlHelper.Reset();
* // 执行SQL命令2
* sqlHelper.Query(sDBQuery2, ...);
* // 如果这是最后一条命令,不需要手动重置,析构函数会自动重置
*/
#include "_osdef.h"
#include "SQL.h"
class CSQLConenction;
class CSqlHelper
{
public:
CSqlHelper(CSQLConenction* conn);
~CSqlHelper();
/*
* Comments:
* @Return void:
* @Remark:
*/
void Reset();
/*
* Comments: SQL查询
* Param const char * sQueryFormat:
* Param ...:
* @Return int:
* @Remark:
*/
int Query(const char* sQueryFormat, ...);
/*
* Comments: SQL查询
* Param const char * sQueryText:
* Param const size_t nTextLen:
* @Return int:
* @Remark:
*/
int RealQuery(const char* sQueryText, const size_t nTextLen);
/*
* Comments: SQL命令
* Param const char * sQueryFormat:
* Param ...:
* @Return int:
* @Remark:
*/
int Exec(const char* sQueryFormat, ...);
/*
* Comments: SQL命令
* Param const char * sExecText:
* Param const size_t nTextLen:
* @Return int:
* @Remark:
*/
int RealExec(const char* sExecText, const size_t nTextLen);
private:
CSQLConenction* m_pSQLConnection;
bool m_bNeedReset;
};