This class represents a database connection.
More...
#include <Database.h>
List of all members.
Classes |
class | Exception |
| This class is thrown in case of any database exception. More...
|
class | NoDataException |
| Exception class thrown when no data is available. More...
|
Public Types |
enum | ConnectionMethod { CONNECTION_METHOD_SQLConnect = 0,
CONNECTION_METHOD_SQLDriverConnect
} |
| Used to specify the connection method in the constructor.
More...
|
Public Member Functions |
| Database (const std::string &dsn, const ConnectionMethod connectionMethod=CONNECTION_METHOD_SQLConnect) |
| Constructor creates the database connection.
|
| DEPRECATED (Query newQuery()) |
| Creates a query object for this database.
|
void | voidQuery (const std::string &query) |
| void Query, query the database and don't worry about return types or if its a successful query.
|
long | intQuery (const std::string &query) |
| long Query, query the database for a single integer result.
|
std::string | strQuery (const std::string &query, long bufSize=1000) |
| A Query interface that returns a string result.
|
int | getTransactionCount () const |
| Get the number of nested transactions.
|
virtual | ~Database () |
| Destructor.
|
Static Public Member Functions |
static std::string | escapeString (const std::string &input) |
| Escapes special characters in a string to be sent as part of a database query.
|
static std::string | boolToStr (const bool in) |
| Converts a boolean input to the equivalent database value.
|
Protected Member Functions |
DatabasePimplData & | getPimplData () |
| Get the reference to the private implementation data.
|
Friends |
class | Query |
class | ScopedTransaction |
Detailed Description
This class represents a database connection.
- Todo:
- : Overload the default assignment operator so that database objects can be assigned without causing problems with connection handles
- Examples:
-
complete.cpp, simple.cpp, and transactions.cpp.
Member Enumeration Documentation
Used to specify the connection method in the constructor.
- Enumerator:
CONNECTION_METHOD_SQLConnect |
Use SQLConnect.
|
CONNECTION_METHOD_SQLDriverConnect |
Use SQLDriverConnect.
|
Constructor & Destructor Documentation
SimpleDB::Database::Database |
( |
const std::string & |
dsn, |
|
|
const ConnectionMethod |
connectionMethod = CONNECTION_METHOD_SQLConnect | |
|
) |
| | |
Constructor creates the database connection.
- Parameters:
-
| dsn | The ODBC data source to connect to. |
| connectionMethod | Controls the SQL connection function to call |
virtual SimpleDB::Database::~Database |
( |
|
) |
[virtual] |
Member Function Documentation
static std::string SimpleDB::Database::boolToStr |
( |
const bool |
in |
) |
[static] |
Converts a boolean input to the equivalent database value.
- Parameters:
-
| in | The boolean to convert |
- Returns:
- the converted string.
SimpleDB::Database::DEPRECATED |
( |
Query |
newQuery() |
) |
|
Creates a query object for this database.
- Deprecated:
- use the Query constructor directly instead
- Returns:
- Query The new query object.
static std::string SimpleDB::Database::escapeString |
( |
const std::string & |
input |
) |
[static] |
Escapes special characters in a string to be sent as part of a database query.
- Parameters:
-
| input | The input string to be escaped. |
- Returns:
- The escaped version of the input string.
long SimpleDB::Database::intQuery |
( |
const std::string & |
query |
) |
|
long Query, query the database for a single integer result.
- Exceptions:
-
- Parameters:
-
| query | the query to execute |
- Returns:
- the integer result from the query
std::string SimpleDB::Database::strQuery |
( |
const std::string & |
query, |
|
|
long |
bufSize = 1000 | |
|
) |
| | |
A Query interface that returns a string result.
- Parameters:
-
| query | The query to execute. |
| bufSize | The max size of the string buffer expected to be returned. |
- Returns:
- resultant string of the query.
void SimpleDB::Database::voidQuery |
( |
const std::string & |
query |
) |
|
void Query, query the database and don't worry about return types or if its a successful query.
- Parameters:
-
| query | The query to execute. |
- Examples:
- transactions.cpp.
The documentation for this class was generated from the following file: