Beamlib 3.1.2
This is the Beam C++ class library.
Loading...
Searching...
No Matches
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) 2022 All Right Reserved, Beam Ltd, https://www.beam.ltd.uk
5 * For license see LICENSE.txt at the root of the beamlib source tree.
6 *******************************************************************************
7 */
8#ifndef BMysql_H
9#define BMysql_H 1
10
11#include <BTypes.h>
12#include <BError.h>
13#include <BDict.h>
14#include <BMutex.h>
15#include <mysql/mysql.h>
16
18class BMysql {
19public:
20 BMysql();
21 ~BMysql();
22
23 BError open(BString hostName, BString dataBase, BString userName, BString password);
24 void close();
25
26 BError get(BString table, BString where, BDictString& fields);
27 BError insert(BString table, BDictString fields, BUInt32* id = 0);
28 BError update(BString table, BUInt32 id, BDictString fields);
29 BError del(BString table, BUInt32 id);
30 BError flush();
31
33
34 // Low level routines
36 MYSQL& db();
37 void setDebug(int debug);
38private:
39 MYSQL odb;
40 int oopened;
41 int odebug;
42 BMutex olock;
43// static BMutex olock; // All BMysql instances share this
44};
45
46#endif
uint32_t BUInt32
Definition: BTypes.h:24
BUInt8 cmd
Definition: BoapMc.h:3
Dictionary list class using templates.
Definition: BDict.h:24
Error return class. This class is used to return the error status from a function....
Definition: BError.h:31
Template based list class.
Definition: BList.h:31
Mutex class. Note these are recursive Mutexes and so you need to make sure the number of unlocks equa...
Definition: BMutex.h:14
A class to provide access to a MySQL database.
Definition: BMysql.h:18
BError insert(BString table, BDictString fields, BUInt32 *id=0)
Definition: BMysql.cpp:94
BError query(BString cmd, BList< BDictString > &result)
Definition: BMysql.cpp:150
BError del(BString table, BUInt32 id)
Delete record from table.
Definition: BMysql.cpp:139
MYSQL & db()
Definition: BMysql.cpp:40
BMysql()
Definition: BMysql.cpp:29
void setDebug(int debug)
Definition: BMysql.cpp:44
BError update(BString table, BUInt32 id, BDictString fields)
Definition: BMysql.cpp:120
BError flush()
Flush all data to disk.
Definition: BMysql.cpp:188
~BMysql()
Definition: BMysql.cpp:34
BError get(BString table, BString where, BDictString &fields)
Definition: BMysql.cpp:76
BString escapeString(BString str)
Escapes special characters in the string.
Definition: BMysql.cpp:194
BError open(BString hostName, BString dataBase, BString userName, BString password)
Definition: BMysql.cpp:48
void close()
Definition: BMysql.cpp:69
This class stores and manipulates ASCII strings.
Definition: BString.h:20