dal::MySqlDataProvider Class Reference

A MySQL Data Provider. More...

#include <mysqldataprovider.h>

Inheritance diagram for dal::MySqlDataProvider:

dal::DataProvider

List of all members.

Public Types

enum  { AUTOCOMMIT_OFF = 0, AUTOCOMMIT_ON = 1 }
 Replacement for mysql my_bool datatype used in mysql_autocommit() function.

Public Member Functions

 MySqlDataProvider (void) throw ()
 Constructor.
 ~MySqlDataProvider (void) throw ()
 Destructor.
DbBackends getDbBackend (void) const throw ()
 Get the name of the database backend.
void connect ()
 Create a connection to the database.
const RecordSetexecSql (const std::string &sql, const bool refresh=false)
 Execute a SQL query.
void disconnect (void)
 Close the connection to the database.
void beginTransaction (void) throw (std::runtime_error)
 Starts a transaction.
void commitTransaction (void) throw (std::runtime_error)
 Commits a transaction.
void rollbackTransaction (void) throw (std::runtime_error)
 Rollback a transaction.
const unsigned int getModifiedRows (void) const
 Returns the number of changed rows by the last executed SQL statement.
const unsigned int getLastId (void) const
 Returns the last inserted value of an autoincrement column after an INSERT statement.


Detailed Description

A MySQL Data Provider.

Definition at line 44 of file mysqldataprovider.h.


Member Function Documentation

DbBackends dal::MySqlDataProvider::getDbBackend ( void   )  const throw () [virtual]

Get the name of the database backend.

Get the database backend name.

Returns:
the database backend name.

Implements dal::DataProvider.

Definition at line 73 of file mysqldataprovider.cpp.

void dal::MySqlDataProvider::connect ( void   )  [virtual]

Create a connection to the database.

Exceptions:
DbConnectionFailure if unsuccessful connection.

Implements dal::DataProvider.

Definition at line 84 of file mysqldataprovider.cpp.

References dal::DataProvider::mDbName, and dal::DataProvider::mIsConnected.

const RecordSet & dal::MySqlDataProvider::execSql ( const std::string &  sql,
const bool  refresh = false 
) [virtual]

Execute a SQL query.

Parameters:
sql the SQL query.
refresh if true, refresh the cache (default = false).
Returns:
a recordset.
Exceptions:
DbSqlQueryExecFailure if unsuccessful execution.
std::runtime_error if trying to query a closed database.

Implements dal::DataProvider.

Definition at line 143 of file mysqldataprovider.cpp.

References dal::RecordSet::add(), dal::RecordSet::clear(), dal::DataProvider::mIsConnected, dal::DataProvider::mRecordSet, dal::DataProvider::mSql, and dal::RecordSet::setColumnHeaders().

Referenced by beginTransaction().

void dal::MySqlDataProvider::disconnect ( void   )  [virtual]

Close the connection to the database.

Exceptions:
DbDisconnectionFailure if unsuccessful disconnection.

Implements dal::DataProvider.

Definition at line 205 of file mysqldataprovider.cpp.

References dal::DataProvider::mIsConnected.

Referenced by ~MySqlDataProvider().

void dal::MySqlDataProvider::beginTransaction ( void   )  throw (std::runtime_error) [virtual]

Starts a transaction.

Exceptions:
std::runtime_error if a transaction is still open

Implements dal::DataProvider.

Definition at line 223 of file mysqldataprovider.cpp.

References execSql(), and dal::DataProvider::mIsConnected.

void dal::MySqlDataProvider::commitTransaction ( void   )  throw (std::runtime_error) [virtual]

Commits a transaction.

Exceptions:
std::runtime_error if no connection is currently open.

Implements dal::DataProvider.

Definition at line 240 of file mysqldataprovider.cpp.

References dal::DataProvider::mIsConnected.

void dal::MySqlDataProvider::rollbackTransaction ( void   )  throw (std::runtime_error) [virtual]

Rollback a transaction.

Exceptions:
std::runtime_error if no connection is currently open.

Implements dal::DataProvider.

Definition at line 261 of file mysqldataprovider.cpp.

References dal::DataProvider::mIsConnected.

const unsigned int dal::MySqlDataProvider::getModifiedRows ( void   )  const [virtual]

Returns the number of changed rows by the last executed SQL statement.

Returns:
Number of rows that have changed.

Implements dal::DataProvider.

Definition at line 282 of file mysqldataprovider.cpp.

References dal::DataProvider::mIsConnected.

const unsigned int dal::MySqlDataProvider::getLastId ( void   )  const [virtual]

Returns the last inserted value of an autoincrement column after an INSERT statement.

Returns:
last autoincrement value.

Implements dal::DataProvider.

Definition at line 308 of file mysqldataprovider.cpp.

References dal::DataProvider::mIsConnected.


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

Generated on Sun Apr 26 17:30:47 2009 for TMW Server Collection by  doxygen 1.5.5