Wt  3.3.8
Public Member Functions | List of all members
Wt::Dbo::SqlConnection Class Referenceabstract

Abstract base class for an SQL connection. More...

#include <Wt/Dbo/SqlConnection>

Inheritance diagram for Wt::Dbo::SqlConnection:
Inheritance graph
[legend]

Public Member Functions

virtual ~SqlConnection ()
 Destructor.
 
virtual SqlConnectionclone () const =0
 Clones the connection. More...
 
virtual void executeSql (const std::string &sql)
 Executes an SQL statement. More...
 
virtual void startTransaction ()=0
 Starts a transaction. More...
 
virtual void commitTransaction ()=0
 Commits a transaction. More...
 
virtual void rollbackTransaction ()=0
 Rolls back a transaction. More...
 
virtual SqlStatementgetStatement (const std::string &id) const
 Returns the statement with the given id. More...
 
virtual void saveStatement (const std::string &id, SqlStatement *statement)
 Saves a statement with the given id. More...
 
virtual SqlStatementprepareStatement (const std::string &sql)=0
 Prepares a statement. More...
 
void setProperty (const std::string &name, const std::string &value)
 Sets a property. More...
 
std::string property (const std::string &name) const
 Returns a property. More...
 
Methods that return dialect information
virtual std::string autoincrementSql () const =0
 Returns the 'autoincrement' SQL type modifier. More...
 
virtual std::vector< std::string > autoincrementCreateSequenceSql (const std::string &table, const std::string &id) const =0
 Returns the SQL statement(s) required to create an id sequence. More...
 
virtual std::vector< std::string > autoincrementDropSequenceSql (const std::string &table, const std::string &id) const =0
 Returns the SQL statement(s) required to drop an id sequence. More...
 
virtual std::string autoincrementType () const =0
 Returns the 'autoincrement' SQL type. More...
 
virtual std::string autoincrementInsertSuffix (const std::string &id) const =0
 Returns the suffix for an 'autoincrement' insert statement. More...
 
virtual void prepareForDropTables ()
 Execute code before dropping the tables. More...
 
virtual const char * dateTimeType (SqlDateTimeType type) const =0
 Returns the date/time type. More...
 
virtual const char * blobType () const =0
 Returns the blob type. More...
 
virtual std::string textType (int size) const
 Returns the text type. More...
 
virtual std::string longLongType () const
 Returns the 64-bit integer type. More...
 
virtual const char * booleanType () const
 Returns the boolean type. More...
 
virtual bool supportUpdateCascade () const
 Returns the true if the database supports Update Cascade. More...
 
virtual bool requireSubqueryAlias () const
 Returns the true if the database require subquery alias. More...
 
virtual LimitQuery limitQueryMethod () const
 Returns the 'autoincrement' SQL type modifier. More...
 
virtual bool usesRowsFromTo () const
 Returns whether the SQL dialect uses 'ROWS ? TO ?', limit or rownum for partial select results. More...
 
virtual bool supportAlterTable () const
 Returns true if the backend support Alter Table. More...
 
virtual bool supportDeferrableFKConstraint () const
 Returns true if the backend supports "deferrable initially deferred" foreign key constraints. More...
 
virtual const char * alterTableConstraintString () const
 Returns the command used in alter table .. drop constraint .. More...
 

Detailed Description

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.

All methods will throw an exception if they could not be completed.

Member Function Documentation

const char * Wt::Dbo::SqlConnection::alterTableConstraintString ( ) const
virtual

Returns the command used in alter table .. drop constraint ..

This method will return "constraint" by default. Default: ALTER TABLE .. DROP CONSTRAINT ..

Reimplemented in Wt::Dbo::backend::MySQL.

virtual std::vector<std::string> Wt::Dbo::SqlConnection::autoincrementCreateSequenceSql ( const std::string &  table,
const std::string &  id 
) const
pure virtual

Returns the SQL statement(s) required to create an id sequence.

This is used by Session::createTables() to create the id sequence for a table. The table's name and primary key are passed as arguments to this function and can be used to construct an SQL sequence that is unique for the table.

Implemented in Wt::Dbo::backend::Postgres, Wt::Dbo::backend::Sqlite3, Wt::Dbo::backend::MySQL, and Wt::Dbo::backend::Firebird.

virtual std::vector<std::string> Wt::Dbo::SqlConnection::autoincrementDropSequenceSql ( const std::string &  table,
const std::string &  id 
) const
pure virtual

Returns the SQL statement(s) required to drop an id sequence.

This is used by Session::dropTables() to drop the id sequence for a table. The table's name and primary key are passed as arguments to this function and can be used to construct an SQL sequence that is unique for the table.

Implemented in Wt::Dbo::backend::Postgres, Wt::Dbo::backend::Sqlite3, Wt::Dbo::backend::MySQL, and Wt::Dbo::backend::Firebird.

virtual std::string Wt::Dbo::SqlConnection::autoincrementInsertSuffix ( const std::string &  id) 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, Wt::Dbo::backend::Sqlite3, Wt::Dbo::backend::MySQL, and Wt::Dbo::backend::Firebird.

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, Wt::Dbo::backend::Sqlite3, Wt::Dbo::backend::MySQL, and Wt::Dbo::backend::Firebird.

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, Wt::Dbo::backend::Sqlite3, Wt::Dbo::backend::MySQL, and Wt::Dbo::backend::Firebird.

virtual const char* Wt::Dbo::SqlConnection::blobType ( ) const
pure virtual
const char * Wt::Dbo::SqlConnection::booleanType ( ) const
virtual

Returns the boolean type.

This method will return "boolean" by default.

Reimplemented in Wt::Dbo::backend::Firebird.

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::Firebird, Wt::Dbo::backend::Sqlite3, Wt::Dbo::backend::MySQL, and Wt::Dbo::backend::Postgres.

virtual void Wt::Dbo::SqlConnection::commitTransaction ( )
pure virtual

Commits a transaction.

This function commits a transaction.

Implemented in Wt::Dbo::backend::Postgres, Wt::Dbo::backend::Sqlite3, Wt::Dbo::backend::MySQL, and Wt::Dbo::backend::Firebird.

virtual const char* Wt::Dbo::SqlConnection::dateTimeType ( SqlDateTimeType  type) const
pure virtual
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, and Wt::Dbo::backend::MySQL.

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.

See also
saveStatement()
LimitQuery Wt::Dbo::SqlConnection::limitQueryMethod ( ) const
virtual

Returns the 'autoincrement' SQL type modifier.

This is used by Session::createTables() to create the id column.

Reimplemented in Wt::Dbo::backend::Firebird.

std::string Wt::Dbo::SqlConnection::longLongType ( ) const
virtual

Returns the 64-bit integer type.

This method will return "bigint" by default.

void Wt::Dbo::SqlConnection::prepareForDropTables ( )
virtual

Execute code before dropping the tables.

This method is called before calling Session::dropTables(). The default implementation is empty.

Reimplemented in Wt::Dbo::backend::Firebird.

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, Wt::Dbo::backend::Sqlite3, Wt::Dbo::backend::MySQL, and Wt::Dbo::backend::Firebird.

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.

See also
setProperty()
bool Wt::Dbo::SqlConnection::requireSubqueryAlias ( ) const
virtual

Returns the true if the database require subquery alias.

This method will return false by default.

Reimplemented in Wt::Dbo::backend::Postgres, and Wt::Dbo::backend::MySQL.

virtual void Wt::Dbo::SqlConnection::rollbackTransaction ( )
pure virtual

Rolls back a transaction.

This function rolls back a transaction.

Implemented in Wt::Dbo::backend::Postgres, Wt::Dbo::backend::Sqlite3, Wt::Dbo::backend::MySQL, and Wt::Dbo::backend::Firebird.

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, Wt::Dbo::backend::Sqlite3, Wt::Dbo::backend::MySQL, and Wt::Dbo::backend::Firebird.

bool Wt::Dbo::SqlConnection::supportAlterTable ( ) const
virtual

Returns true if the backend support Alter Table.

This method will return false by default.

Reimplemented in Wt::Dbo::backend::Postgres, Wt::Dbo::backend::MySQL, and Wt::Dbo::backend::Firebird.

bool Wt::Dbo::SqlConnection::supportDeferrableFKConstraint ( ) const
virtual

Returns true if the backend supports "deferrable initially deferred" foreign key constraints.

This method will return false by default.

Reimplemented in Wt::Dbo::backend::Postgres, and Wt::Dbo::backend::Sqlite3.

bool Wt::Dbo::SqlConnection::supportUpdateCascade ( ) const
virtual

Returns the true if the database supports Update Cascade.

This method will return true by default. Was created for the oracle database which does not support Update Cascade.

std::string Wt::Dbo::SqlConnection::textType ( int  size) const
virtual

Returns the text type.

This is the text type for a string. If size = -1, then a type should be returned which does not require size information, otherwise a type should be returned that limits the size of the stored string to size.

This method will return "text" by default if size = -1, and "varchar(size)" otherwise.

See also
SqlStatement::bind(int column, const std::string& value)

Reimplemented in Wt::Dbo::backend::Firebird.

bool Wt::Dbo::SqlConnection::usesRowsFromTo ( ) const
virtual

Returns whether the SQL dialect uses 'ROWS ? TO ?', limit or rownum for partial select results.

This is an alternative SQL dialect option to the (non-standard) 'OFFSET ? LIMIT ?' syntax.

The default implementation returns Limit.

Reimplemented in Wt::Dbo::backend::Firebird.


Generated on Mon Sep 4 2017 for the C++ Web Toolkit (Wt) by doxygen 1.8.11