Abstract base class for an SQL connection. More...
#include <Wt/Dbo/SqlConnection>
Public Member Functions | |
virtual | ~SqlConnection () |
Destructor. | |
virtual SqlConnection * | clone () const =0 |
Clones the connection. | |
virtual void | executeSql (const std::string &sql) |
Executes an SQL statement. | |
virtual void | startTransaction ()=0 |
Starts a transaction. | |
virtual void | commitTransaction ()=0 |
Commits a transaction. | |
virtual void | rollbackTransaction ()=0 |
Rolls back a transaction. | |
virtual SqlStatement * | getStatement (const std::string &id) const |
Returns the statement with the given id. | |
virtual void | saveStatement (const std::string &id, SqlStatement *statement) |
Saves a statement with the given id. | |
virtual SqlStatement * | prepareStatement (const std::string &sql)=0 |
Prepares a statement. | |
void | setProperty (const std::string &name, const std::string &value) |
Sets a property. | |
std::string | property (const std::string &name) const |
Returns a property. | |
Methods that return dialect information | |
virtual std::string | autoincrementSql () const =0 |
Returns the 'autoincrement' SQL type modifier. | |
virtual std::string | autoincrementType () const =0 |
Returns the 'autoincrement' SQL type. | |
virtual std::string | autoincrementInsertSuffix () const =0 |
Returns the suffix for an 'autoincrement' insert statement. | |
virtual const char * | dateTimeType (SqlDateTimeType type) const =0 |
Returns the date/time type. | |
virtual const char * | blobType () const =0 |
Returns the blob type. |
Abstract base class for an SQL connection.
An sql connection manages a single connection to a database. It also manages a map of previously prepared statements indexed by id's.
This class is part of Wt::Dbo's backend API, and should not be used directly.
virtual std::string Wt::Dbo::SqlConnection::autoincrementInsertSuffix | ( | ) | const [pure virtual] |
Returns the suffix for an 'autoincrement' insert statement.
This is appended to the insert
statement, since some back-ends need to be indicated that they should return the autoincrement id.
Implemented in Wt::Dbo::backend::Postgres, and Wt::Dbo::backend::Sqlite3.
virtual std::string Wt::Dbo::SqlConnection::autoincrementSql | ( | ) | const [pure virtual] |
Returns the 'autoincrement' SQL type modifier.
This is used by Session::createTables() to create the id column.
Implemented in Wt::Dbo::backend::Postgres, and Wt::Dbo::backend::Sqlite3.
virtual std::string Wt::Dbo::SqlConnection::autoincrementType | ( | ) | const [pure virtual] |
Returns the 'autoincrement' SQL type.
This is used by Session::createTables() to create the id column.
Implemented in Wt::Dbo::backend::Postgres, and Wt::Dbo::backend::Sqlite3.
virtual const char* Wt::Dbo::SqlConnection::blobType | ( | ) | const [pure virtual] |
Returns the blob type.
Implemented in Wt::Dbo::backend::Postgres, and Wt::Dbo::backend::Sqlite3.
virtual SqlConnection* Wt::Dbo::SqlConnection::clone | ( | ) | const [pure virtual] |
Clones the connection.
Returns a new connection object that is configured like this object. This is used by connection pool implementations to create its connections.
Implemented in Wt::Dbo::backend::Postgres, and Wt::Dbo::backend::Sqlite3.
virtual void Wt::Dbo::SqlConnection::commitTransaction | ( | ) | [pure virtual] |
Commits a transaction.
This function commits a transaction.
Implemented in Wt::Dbo::backend::Postgres, and Wt::Dbo::backend::Sqlite3.
virtual const char* Wt::Dbo::SqlConnection::dateTimeType | ( | SqlDateTimeType | type ) | const [pure virtual] |
Returns the date/time type.
Implemented in Wt::Dbo::backend::Postgres, and Wt::Dbo::backend::Sqlite3.
void Wt::Dbo::SqlConnection::executeSql | ( | const std::string & | sql ) | [virtual] |
Executes an SQL statement.
This is a convenience method for preparing a statement, executing it, and deleting it.
Reimplemented in Wt::Dbo::backend::Postgres.
SqlStatement * Wt::Dbo::SqlConnection::getStatement | ( | const std::string & | id ) | const [virtual] |
Returns the statement with the given id.
Returns 0 if no such statement was already added.
virtual SqlStatement* Wt::Dbo::SqlConnection::prepareStatement | ( | const std::string & | sql ) | [pure virtual] |
Prepares a statement.
Returns the prepared statement.
Implemented in Wt::Dbo::backend::Postgres, and Wt::Dbo::backend::Sqlite3.
std::string Wt::Dbo::SqlConnection::property | ( | const std::string & | name ) | const |
Returns a property.
Returns the property value, or an empty string if the property was not set.
virtual void Wt::Dbo::SqlConnection::rollbackTransaction | ( | ) | [pure virtual] |
Rolls back a transaction.
This function rolls back a transaction.
Implemented in Wt::Dbo::backend::Postgres, and Wt::Dbo::backend::Sqlite3.
void Wt::Dbo::SqlConnection::saveStatement | ( | const std::string & | id, |
SqlStatement * | statement | ||
) | [virtual] |
Saves a statement with the given id.
Saves the statement for future reuse using getStatement()
void Wt::Dbo::SqlConnection::setProperty | ( | const std::string & | name, |
const std::string & | value | ||
) |
Sets a property.
Properties may tailor the backend behavior. Some properties are applicable to all backends, while some are backend specific.
General properties are:
show-queries
: when value is "true", queries are shown as they are executed. virtual void Wt::Dbo::SqlConnection::startTransaction | ( | ) | [pure virtual] |
Starts a transaction.
This function starts a transaction.
Implemented in Wt::Dbo::backend::Postgres, and Wt::Dbo::backend::Sqlite3.