#include <database.h>
Public Member Functions | |
int | getResultCount () const |
long | getLastInsertRowID () const |
cRows * | getResultRows () const |
int | execStatement (const char *Statement,...) |
void | startTransaction () |
void | commitTransaction () |
void | rollbackTransaction () |
void | setAutoCommit (bool Commit=true) |
Static Public Member Functions | |
static const char * | sprintf (const char *Format,...) |
static cSQLiteDatabase * | getInstance () |
Friends | |
class | cStatement |
This is a wrapper class for a SQLite3 database connection It supports simple execution functions.
On requests with returns any results a instance of cRows*
will be created.
void cSQLiteDatabase::commitTransaction | ( | ) |
Commits a transaction
This function commits the transaction and writes all changes to the database
int cSQLiteDatabase::execStatement | ( | const char * | Statement, | |
... | ||||
) |
Executes a SQL statement
This will execute the statement in the first parameter. If it is followed by any optional parameters it will be formated using the same function as in cSQLiteDatabase::sprintf()
.
-1
, in case of an error0
, when the statement was executed successfuly Statement | Statement to be executed |
cSQLiteDatabase * cSQLiteDatabase::getInstance | ( | ) | [static] |
Returns the instance of the database
Returns the instance of the SQLite database. This will create a single instance of none is existing on the very first call. A subsequent call will return the same instance.
long cSQLiteDatabase::getLastInsertRowID | ( | ) | const |
The last INSERT
RowID
Returns the primary key of the last inserted row. This will only work if there are no successive calls to the database.
int cSQLiteDatabase::getResultCount | ( | ) | const [inline] |
Row count of the last result
Returns the row count of the last {SQL
SELECT} request.
cRows* cSQLiteDatabase::getResultRows | ( | ) | const [inline] |
Result set of the last request
Returns the result rows of the SQL SELECT request. This might be NULL, if the last statement was not a SELECT.
SELECT
statement. void cSQLiteDatabase::rollbackTransaction | ( | ) |
Performs a rollback on a transaction
This function performs a rollback. No changes will be made to the database
void cSQLiteDatabase::setAutoCommit | ( | bool | Commit = true |
) | [inline] |
Set the commit behavior
This function sets the auto commit behavior on new transactions with
true
, commits the last transaction before starting a new onefalse
, performs a rollback on the old transaction Commit | Switches the behavior of auto commit |
const char * cSQLiteDatabase::sprintf | ( | const char * | Format, | |
... | ||||
) | [static] |
Prints a SQLite escaped text
Returns a formated text with special characters to escape SQLite special characters like "'". Additionally to the well known characters of printf the following are allowed:
q
, like s, escapes single quotes in stringsQ
, like q, surrounds the escaped string with additional single quotesz
, frees the string after reading and coping it
Format | The format string |
void cSQLiteDatabase::startTransaction | ( | ) |
Starts a transaction
This starts a new transaction and commits or rolls back a previous.