123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- #ifndef __SQL_STATEMENT_IMPL_HEADER__
- #define __SQL_STATEMENT_IMPL_HEADER__
- #pragma once
- enum SQLSTATEMENTKIND
- {
- KIND_INSERT = 1,
- KIND_UPDATE = 2
- };
- class CSQLStatementImpl
- {
- CSQLStatementImpl();
- protected:
- CString m_strSQL;
- CString m_strTableName;
- CString m_strFilter;
- int m_nStatementKind; // 1==Insert, 2==Update;
-
- int m_nCount;
- int m_nSzie;
- CStringArray m_saFields;
- CStringArray m_saValues;
- public:
- ~CSQLStatementImpl();
- inline static CSQLStatementImpl *GetInstancePtr()
- {
- static CSQLStatementImpl lInstance;
- return &lInstance;
- }
- inline void ReSetKind(LPCTSTR lpTableName,LPCTSTR lpFilter,const int &nStatementKind,const int &nSize)
- {
- m_nStatementKind = nStatementKind;
- //if(m_nStatementKind == KIND_UPDATE)
- m_strTableName = lpTableName;
- m_strFilter = lpFilter;
-
- m_nCount = 0;
- m_nSzie = nSize;
- // SetSize之后,必须调用RemoveAll,否则Add时元素位置是从m_nSize开始,而不是从0开始;
- m_saFields.SetSize(m_nSzie,256);
- m_saValues.SetSize(m_nSzie,256);
- m_saFields.RemoveAll();
- m_saValues.RemoveAll();
- }
- void AddElement(LPCTSTR lpField, LPCTSTR lpValue);
- void AddElement(LPCTSTR lpField, CONST INT &nValue);
- CString ReturnSQL();
- void ReturnSQL(CString &strSQL);
- };
- #endif
|