Beam-lib  2.16.3
This is the Beam C++ class library.
BMysql.h
Go to the documentation of this file.
1 /*******************************************************************************
2  * BMysql.h BDS Database Access Object
3  * T.Barnaby, BEAM Ltd, 2008-05-20
4  * Copyright (c) 2012 All Right Reserved, Beam Ltd, http://www.beam.ltd.uk
5  *******************************************************************************
6  */
7 #ifndef BMysql_H
8 #define BMysql_H 1
9 
10 #include <BTypes.h>
11 #include <BError.h>
12 #include <BDict.h>
13 #include <BMutex.h>
14 #include <mysql/mysql.h>
15 
16 class BMysql {
17 public:
18  BMysql();
19  ~BMysql();
20 
21  BError open(BString hostName, BString dataBase, BString userName, BString password);
22  void close();
23 
24  BError get(BString table, BString where, BDictString& fields);
25  BError insert(BString table, BDictString fields, BUInt32* id = 0);
26  BError update(BString table, BUInt32 id, BDictString fields);
27  BError del(BString table, BUInt32 id);
28  BError flush();
29 
31 
32  // Low level routines
34  MYSQL& db();
35  void setDebug(int debug);
36 private:
37  MYSQL odb;
38  int oopened;
39  int odebug;
40  BMutex olock;
41 // static BMutex olock; // All BMysql instances share this
42 };
43 
44 #endif
MYSQL & db()
Definition: BMysql.cpp:39
void setDebug(int debug)
Definition: BMysql.cpp:43
Definition: BString.h:18
Template based list class.
Definition: BList.h:30
BError get(BString table, BString where, BDictString &fields)
Definition: BMysql.cpp:75
BUInt8 cmd
Definition: BoapMc.h:385
BError flush()
Flush all data to disk.
Definition: BMysql.cpp:187
~BMysql()
Definition: BMysql.cpp:33
uint32_t BUInt32
Definition: BTypes.h:21
BError insert(BString table, BDictString fields, BUInt32 *id=0)
Definition: BMysql.cpp:93
Definition: BMysql.h:16
BError del(BString table, BUInt32 id)
Delete record from table.
Definition: BMysql.cpp:138
Definition: BMutex.h:14
BString escapeString(BString str)
Escapes special characters in the string.
Definition: BMysql.cpp:193
Definition: BDict.h:22
void close()
Definition: BMysql.cpp:68
Definition: BError.h:25
BMysql()
Definition: BMysql.cpp:28
BError query(BString cmd, BList< BDictString > &result)
Definition: BMysql.cpp:149
BError open(BString hostName, BString dataBase, BString userName, BString password)
Definition: BMysql.cpp:47
BError update(BString table, BUInt32 id, BDictString fields)
Definition: BMysql.cpp:119