cSQLiteDatabase Class Reference

#include <database.h>

Collaboration diagram for cSQLiteDatabase:

Collaboration graph
[legend]

List of all members.

Public Member Functions

int getResultCount () const
long getLastInsertRowID () const
cRowsgetResultRows () 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 cSQLiteDatabasegetInstance ()

Friends

class cStatement


Detailed Description

SQLite Database

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.


Member Function Documentation

void cSQLiteDatabase::commitTransaction (  ) 

Commits a transaction

This function commits the transaction and writes all changes to the database

See also:
cSQLiteDatabase::startTransaction

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().

See also:
cSQLiteDatabase::sprintf().
Returns:
returns an integer representing
  • -1, in case of an error
  • 0, when the statement was executed successfuly
Parameters:
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.

Returns:
the database 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.

Returns:
the last insert RowID

int cSQLiteDatabase::getResultCount (  )  const [inline]

Row count of the last result

Returns the row count of the last {SQL SELECT} request.

See also:
cRows
Returns:
the result row count

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.

See also:
cRows
Returns:
the result rows of the last SELECT statement.

void cSQLiteDatabase::rollbackTransaction (  ) 

Performs a rollback on a transaction

This function performs a rollback. No changes will be made to the database

See also:
cSQLiteDatabase::rollbackTransaction

void cSQLiteDatabase::setAutoCommit ( bool  Commit = true  )  [inline]

Set the commit behavior

This function sets the auto commit behavior on new transactions with

See also:
cSQLiteDatabase::startTransaction.
  • true, commits the last transaction before starting a new one
  • false, performs a rollback on the old transaction
Parameters:
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 strings
  • Q, like q, surrounds the escaped string with additional single quotes
  • z, frees the string after reading and coping it

See also:
sprintf()
Returns:
the formated string
Parameters:
Format The format string

void cSQLiteDatabase::startTransaction (  ) 

Starts a transaction

This starts a new transaction and commits or rolls back a previous.

See also:
cSQLiteDatabase::setAutoCommit

cSQLiteDatabase::commitTransaction


The documentation for this class was generated from the following files:

Generated on Sun Nov 8 15:44:09 2009 for UPnP/DLNA plugin for VDR by  doxygen 1.5.8