HCE project C++ developers source code library  1.1.1
HCE project developer library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
MysqlLite.h
Go to the documentation of this file.
1 #ifndef MYSQLLITE_H
2 #define MYSQLLITE_H
3 #include <stdlib.h>
4 #include <stdio.h>
5 #include <stdarg.h>
6 #include <mysql.h>
7 #include <string.h>
8 
9 class PreparedQuery;
10 
11 class MysqlLite
12 {
13 public:
14  MysqlLite(const char *host, const char *user, const char *passwd,
15  const char *db, unsigned int port = 0, const char *socket = NULL, bool connectNow = true);
16  ~MysqlLite();
17 
18  bool query(const char *pattern, ...);
19  MYSQL_RES *store();
20  MYSQL_RES *use();
21  MYSQL_ROW fetch(MYSQL_RES *);
22  bool is_connect();
23  my_ulonglong insertId();
24  const char *errorStr();
25  void freeResult(MYSQL_RES * res)
26  {
27  mysql_free_result(res);
28  }
29  bool setCharacterSet(const char *character);
30  const char *errStr();
31  unsigned int errNo();
32  char *escapeStr(const char *str);
33  my_ulonglong affectedRows();
34  my_ulonglong numRows(MYSQL_RES * res);
35  void setTimeout(unsigned int readTimeout, unsigned int writeTimeout);
36  bool ping();
37  bool reconnect();
38  void disconnect();
39 private:
40  bool connected;
41  MYSQL *sql;
42  friend class PreparedQuery;
43  char *host;
44  char *user;
45  char *passwd;
46  char *db;
47  unsigned int port;
48  char *socket;
49 };
50 
52 {
53  public:
54  PreparedQuery(const char *query, MysqlLite *sql);
56  bool execute();
57  MYSQL_BIND* operator[](int index);
58  bool bind();
59  const char *errorStr();
60  unsigned int errNo(){return mysql_stmt_errno(stmt);}
61 
62  private:
63  MYSQL_STMT *stmt;
64  MYSQL_BIND *bindParam;
65  int paramCount;
66 };
67 #endif