SQLStatementImpl.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #ifndef __SQL_STATEMENT_IMPL_HEADER__
  2. #define __SQL_STATEMENT_IMPL_HEADER__
  3. #pragma once
  4. enum SQLSTATEMENTKIND
  5. {
  6. KIND_INSERT = 1,
  7. KIND_UPDATE = 2
  8. };
  9. class CSQLStatementImpl
  10. {
  11. CSQLStatementImpl();
  12. protected:
  13. CString m_strSQL;
  14. CString m_strTableName;
  15. CString m_strFilter;
  16. int m_nStatementKind; // 1==Insert, 2==Update;
  17. int m_nCount;
  18. int m_nSzie;
  19. CStringArray m_saFields;
  20. CStringArray m_saValues;
  21. public:
  22. ~CSQLStatementImpl();
  23. inline static CSQLStatementImpl *GetInstancePtr()
  24. {
  25. static CSQLStatementImpl lInstance;
  26. return &lInstance;
  27. }
  28. inline void ReSetKind(LPCTSTR lpTableName,LPCTSTR lpFilter,const int &nStatementKind,const int &nSize)
  29. {
  30. m_nStatementKind = nStatementKind;
  31. m_strTableName = lpTableName;
  32. m_strFilter = lpFilter;
  33. m_nCount = 0;
  34. m_nSzie = nSize;
  35. // SetSize之后,必须调用RemoveAll,否则Add时元素位置是从m_nSize开始,而不是从0开始;
  36. m_saFields.SetSize(m_nSzie,256);
  37. m_saValues.SetSize(m_nSzie,256);
  38. m_saFields.RemoveAll();
  39. m_saValues.RemoveAll();
  40. }
  41. void AddElement(LPCTSTR lpField,LPCTSTR lpValue);
  42. void AddElement(LPCTSTR lpField,CONST INT &nValue);
  43. CString ReturnSQL();
  44. void ReturnSQL(CString &strSQL);
  45. };
  46. #endif