SourceForge.net Logo

dbfacade::Database Class Reference

#include <dbfacade.h>

Inheritance diagram for dbfacade::Database:

Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual ~Database ()
virtual void connect (const std::string &server, const std::string &username, const std::string &password, const std::string &dbname)=0
virtual void execute (const std::string &statement)=0
virtual ResultPtr sqlSelect (const std::string &statement, const bool allAtOnce=true)=0
virtual int sqlInsert (const std::string &statement)=0
virtual int sqlUpdate (const std::string &statement)=0
virtual bool getFirstBoolean (const std::string &statement)
virtual double getFirstDouble (const std::string &statement)
virtual int getFirstInt (const std::string &statement)
virtual std::string getFirstString (const std::string &statement)
virtual std::string escape (const char *unescaped, const int size) const =0

Static Public Member Functions

static boost::shared_ptr
< Database
getDatabase (const std::string &identifier)


Detailed Description

Represents a connection to a database.

Constructor & Destructor Documentation

Database::~Database (  )  [virtual]


Member Function Documentation

static boost::shared_ptr<Database> dbfacade::Database::getDatabase ( const std::string &  identifier  )  [static]

A factory that returns the appropriate type of database.

virtual void dbfacade::Database::connect ( const std::string &  server,
const std::string &  username,
const std::string &  password,
const std::string &  dbname 
) [pure virtual]

Establishes a connection to a database.

Implemented in DatabaseMySQL, DatabasePostgreSQL, and DatabaseSQLite.

virtual void dbfacade::Database::execute ( const std::string &  statement  )  [pure virtual]

Called by sqlSelect, sqlInsert and sqlUpdate.

Implemented in DatabaseMySQL, DatabasePostgreSQL, and DatabaseSQLite.

virtual ResultPtr dbfacade::Database::sqlSelect ( const std::string &  statement,
const bool  allAtOnce = true 
) [pure virtual]

Returns the result of the select statement.

Implemented in DatabaseMySQL, DatabasePostgreSQL, and DatabaseSQLite.

virtual int dbfacade::Database::sqlInsert ( const std::string &  statement  )  [pure virtual]

MySQL:

  • Returns the first automatically generated AUTO_INCREMENT value (or the AUTO_INCREMENT value of the previously inserted row or 0 if there isn't one).
  • Throws an exception if VARCHARs are too long. PostgreSQL:
  • Returns the inserted OID (or 0 if no the table has no OIDs).
  • Truncates VARCHARs that are too long.

Implemented in DatabaseMySQL, DatabasePostgreSQL, and DatabaseSQLite.

virtual int dbfacade::Database::sqlUpdate ( const std::string &  statement  )  [pure virtual]

Returns the number of affected rows.

Implemented in DatabaseMySQL, DatabasePostgreSQL, and DatabaseSQLite.

virtual bool dbfacade::Database::getFirstBoolean ( const std::string &  statement  )  [virtual]

Returns the first column of the first row of the result.

virtual double dbfacade::Database::getFirstDouble ( const std::string &  statement  )  [virtual]

Returns the first column of the first row of the result.

virtual int dbfacade::Database::getFirstInt ( const std::string &  statement  )  [virtual]

Returns the first column of the first row of the result.

virtual std::string dbfacade::Database::getFirstString ( const std::string &  statement  )  [virtual]

Returns the first column of the first row of the result.

virtual std::string dbfacade::Database::escape ( const char *  unescaped,
const int  size 
) const [pure virtual]

Replaces characters by escape sequences.

Implemented in DatabaseMySQL, DatabasePostgreSQL, and DatabaseSQLite.


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

Generated on Mon Mar 16 20:04:35 2009 for libdbfacade.so by  doxygen 1.5.5