DSL
DB_MySQL.h
1 //@AUTOHEADER@BEGIN@
2 /***********************************************************************\
3 | Drift Standard Libraries v1.01 |
4 | Copyright 2010-2023 Drift Solutions / Indy Sams |
5 | Docs and more information available at https://www.driftsolutions.dev |
6 | This file released under the 3-clause BSD license, |
7 | see included DSL.LICENSE.TXT file for details. |
8 \***********************************************************************/
9 //@AUTOHEADER@END@
10 
11 #ifndef _INCLUDE_SQLCONX_H_
12 #define _INCLUDE_SQLCONX_H_
13 
14 #include <drift/DB_Common.h>
15 #include <mysql/mysql.h>
16 
17 #if defined(DSL_DLL) && defined(WIN32)
18  #if defined(DSL_MYSQL_EXPORTS)
19  #define DSL_MYSQL_API extern "C" __declspec(dllexport)
20  #define DSL_MYSQL_API_CLASS __declspec(dllexport)
21  #else
22  #define DSL_MYSQL_API extern "C" __declspec(dllimport)
23  #define DSL_MYSQL_API_CLASS __declspec(dllimport)
24  #endif
25 #else
26  #define DSL_MYSQL_API DSL_API_VIS
27  #define DSL_MYSQL_API_CLASS DSL_API_VIS
28 #endif
29 
30 class DSL_MYSQL_API_CLASS DB_MySQL: public SQLConx {
31 public:
32  DB_MySQL();
33  ~DB_MySQL();
34 
35  bool Connect(std::string host, std::string user, std::string pass, std::string dbname, uint16_t port=0, std::string charset="");
36  bool Connect();
37  void Disconnect();
38  int Ping();
39 
40  std::string GetErrorString();
41  unsigned int GetError();
42 
43  bool NoResultQuery(std::string query);
44  MYSQL_RES *Query(std::string query);
45  uint64_t NumRows(MYSQL_RES *result);
46  bool FetchRow(MYSQL_RES *result, SC_Row& retRow);
47  bool FreeResult(MYSQL_RES *result);
48 
49  uint32_t InsertID();
50  uint64_t InsertID64();
51  uint64_t AffectedRows();
52  uint32_t GetQueryCount();
53 
54  std::string EscapeString(std::string str);
55  MYSQL * GetHandle();
56 
57  SQLConxMulti * MultiStart();
58  bool MultiSend(SQLConxMulti *);
59  bool MultiEnd(SQLConxMulti *);
60 
61 private:
62  MYSQL * sql;
63  std::string host, user, pass, dbname, charset;
64  uint16_t port;
65  uint32_t query_count = 0;
66 };
67 
68 #endif // _INCLUDE_SQLCONX_H_
Definition: DB_MySQL.h:30
Definition: DB_Common.h:14
Definition: DB_Common.h:26
Definition: DB_Common.h:36