Generic Database. More...
#include <rdb.h>
Public Types | |
enum | Db { MySQL, SQLite, PostgreSQL } |
Public Member Functions | |
RDb (Db type) | |
Db | GetType (void) const |
virtual void | CreateTransactionTable (const RString &name, size_t nb,...) |
virtual size_t | GetLastInsertId (void)=0 |
virtual void * | InitQuery (const RString &sql, size_raw &nbcols)=0 |
virtual void | ReleaseQuery (void *data)=0 |
virtual bool | EndQuery (const void *data)=0 |
virtual void | StartQuery (void *data)=0 |
virtual void | NextQuery (void *data)=0 |
virtual RString | GetField (const void *data, size_t index)=0 |
void | RunSQLFile (const RURI &file, bool coutit=false) |
virtual | ~RDb (void) |
Protected Attributes | |
Db | Type |
Detailed Description
Generic Database.
The RDb pure class provides a representation of connection to a database. Actually, MySQL and SQLite child classes are supported.
Member Enumeration Documentation
enum Db |
Constructor & Destructor Documentation
|
virtual |
Destruct the connection to the database.
Member Function Documentation
Db GetType | ( | void | ) | const |
Get the type of the database.
|
virtual |
Create a table that will be used to simulate transactions.
- Parameters
-
name Name of the transaction. nb Number of parameters. ... Name of the parameters of the transaction (transid is reserved).
|
pure virtual |
Get the last auto-increment identifier inserted.
Implemented in RDbPostgreSQL, RDbMySQL, and RDbSQLite.
Initialize a query.
- Parameters
-
sql SQL query. nbcols Number of columns of the query (assigned by the method).
- Returns
- Pointer to a structure allocated by the database.
Implemented in RDbPostgreSQL, RDbMySQL, and RDbSQLite.
|
pure virtual |
Release a query.
- Parameters
-
data Database-dependent data.
Implemented in RDbPostgreSQL, RDbMySQL, and RDbSQLite.
|
pure virtual |
- Parameters
-
data Database-dependent data.
- Returns
- true if all the rows of a query are treated.
Implemented in RDbPostgreSQL, RDbMySQL, and RDbSQLite.
|
pure virtual |
Start a query.
- Parameters
-
data Database-dependent data.
Implemented in RDbPostgreSQL, RDbMySQL, and RDbSQLite.
|
pure virtual |
Read the next row of the query.
- Parameters
-
data Database-dependent data.
Implemented in RDbPostgreSQL, RDbMySQL, and RDbSQLite.
|
pure virtual |
Return a specific field of the current row.
- Parameters
-
data Database-dependent data. index Index of the field in the query.
Implemented in RDbPostgreSQL, RDbMySQL, and RDbSQLite.
void RunSQLFile | ( | const RURI & | file, |
bool | coutit = false |
||
) |
Run file containing SQL commands. The file is supposed to be encoded in utf-8. Lines starting with C comment with "!", "--" or "#" are considered as comments and not send to the database.
- Parameters
-
file File to execute. coutit If yes, each SQL query is printed on screen.
Field Documentation
|
protected |
Type of the database.