Wt 3.3.12
Loading...
Searching...
No Matches
Public Member Functions | List of all members
Wt::Dbo::backend::MySQL Class Reference

A MySQL connection. More...

#include <Wt/Dbo/backend/MySQL>

Inheritance diagram for Wt::Dbo::backend::MySQL:
Inheritance graph
[legend]

Public Member Functions

 MySQL (const std::string &db, const std::string &dbuser="root", const std::string &dbpasswd="", const std::string dbhost="localhost", unsigned int dbport=0, const std::string &dbsocket="/var/run/mysqld/mysqld.sock", int fractionalSecondsPart=-1)
 Opens a new MySQL backend connection.
 
 MySQL (const MySQL &other)
 Copies a MySQL connection.
 
 ~MySQL ()
 Destructor.
 
virtual MySQLclone () const
 Returns a copy of the connection.
 
bool connect (const std::string &db, const std::string &dbuser="root", const std::string &dbpasswd="", const std::string &dbhost="localhost", unsigned int dbport=0, const std::string &dbsocket="/var/run/mysqld/mysqld.sock")
 Tries to connect.
 
MySQL_impl * connection ()
 Returns the underlying connection.
 
virtual void executeSql (const std::string &sql)
 Executes an SQL statement.
 
virtual void startTransaction ()
 Starts a transaction.
 
virtual void commitTransaction ()
 Commits a transaction.
 
virtual void rollbackTransaction ()
 Rolls back a transaction.
 
virtual SqlStatementprepareStatement (const std::string &sql)
 Prepares a statement.
 
- Public Member Functions inherited from Wt::Dbo::SqlConnection
virtual ~SqlConnection ()
 Destructor.
 
virtual void executeSqlStateful (const std::string &sql)
 Executes a connection-stateful SQL statement.
 
virtual SqlStatementgetStatement (const std::string &id)
 Returns the statement with the given id.
 
virtual void saveStatement (const std::string &id, SqlStatement *statement)
 Saves a statement with the given id.
 
void setProperty (const std::string &name, const std::string &value)
 Sets a property.
 
std::string property (const std::string &name) const
 Returns a property.
 
virtual std::string autoincrementInsertInfix (const std::string &id) const
 Returns the infix for an 'autoincrement' insert statement.
 
virtual void prepareForDropTables ()
 Execute code before dropping the tables.
 
virtual std::string textType (int size) const
 Returns the text type.
 
virtual std::string longLongType () const
 Returns the 64-bit integer type.
 
virtual const char * booleanType () const
 Returns the boolean type.
 
virtual bool supportUpdateCascade () const
 Returns true if the database supports Update Cascade.
 
virtual LimitQuery limitQueryMethod () const
 Returns the 'autoincrement' SQL type modifier.
 
virtual bool usesRowsFromTo () const
 Returns whether the SQL dialect uses 'ROWS ? TO ?', limit or rownum for partial select results.
 
virtual bool supportDeferrableFKConstraint () const
 Returns true if the backend supports "deferrable initially deferred" foreign key constraints.
 
bool showQueries () const
 Returns the 'autoincrement' SQL type modifier.
 

Methods that return dialect information

std::string dbname_
 Returns the supported fractional seconds part.
 
std::string dbuser_
 Returns the supported fractional seconds part.
 
std::string dbpasswd_
 Returns the supported fractional seconds part.
 
std::string dbhost_
 Returns the supported fractional seconds part.
 
std::string dbsocket_
 Returns the supported fractional seconds part.
 
unsigned int dbport_
 Returns the supported fractional seconds part.
 
int fractionalSecondsPart_
 Returns the supported fractional seconds part.
 
std::string dateType_
 Returns the supported fractional seconds part.
 
std::string timeType_
 Returns the supported fractional seconds part.
 
MySQL_impl * impl_
 Returns the supported fractional seconds part.
 
virtual std::string autoincrementSql () const
 Returns the supported fractional seconds part.
 
virtual std::string autoincrementType () const
 Returns the supported fractional seconds part.
 
virtual std::string autoincrementInsertSuffix (const std::string &id) const
 Returns the supported fractional seconds part.
 
virtual std::vector< std::string > autoincrementCreateSequenceSql (const std::string &table, const std::string &id) const
 Returns the supported fractional seconds part.
 
virtual std::vector< std::string > autoincrementDropSequenceSql (const std::string &table, const std::string &id) const
 Returns the supported fractional seconds part.
 
virtual const char * dateTimeType (SqlDateTimeType type) const
 Returns the supported fractional seconds part.
 
virtual const char * blobType () const
 Returns the supported fractional seconds part.
 
virtual bool supportAlterTable () const
 Returns the supported fractional seconds part.
 
virtual const char * alterTableConstraintString () const
 Returns the supported fractional seconds part.
 
virtual bool requireSubqueryAlias () const
 Returns the supported fractional seconds part.
 
int getFractionalSecondsPart () const
 Returns the supported fractional seconds part.
 
void setFractionalSecondsPart (int fractionalSecondsPart)
 Set the supported fractional seconds part.
 
void init ()
 Returns the supported fractional seconds part.
 

Additional Inherited Members

- Protected Member Functions inherited from Wt::Dbo::SqlConnection
 SqlConnection ()
 Returns the 'autoincrement' SQL type modifier.
 
 SqlConnection (const SqlConnection &other)
 Returns the 'autoincrement' SQL type modifier.
 
void clearStatementCache ()
 Returns the 'autoincrement' SQL type modifier.
 
std::vector< SqlStatement * > getStatements () const
 Returns the 'autoincrement' SQL type modifier.
 
const std::vector< std::string > & getStatefulSql () const
 Returns the 'autoincrement' SQL type modifier.
 

Detailed Description

A MySQL connection.

This class provides the backend implementation for mariadb databases. It has been tested against MySQL 5.6.

In order to work properly with Wt::Dbo, MySQL must be configured with InnoDB (for MySQL) or XtraDB (for mariadb) as the default database engine - so that the transaction based functionality works.

Note
There is a bug in the implementation of milliseconds in mariadb C client which affects WTime and posix::time_duration values – it goes berserk when fractional part = 0.

Constructor & Destructor Documentation

◆ MySQL() [1/2]

Wt::Dbo::backend::MySQL::MySQL ( const std::string &  db,
const std::string &  dbuser = "root",
const std::string &  dbpasswd = "",
const std::string  dbhost = "localhost",
unsigned int  dbport = 0,
const std::string &  dbsocket = "/var/run/mysqld/mysqld.sock",
int  fractionalSecondsPart = -1 
)

Opens a new MySQL backend connection.

For the connection parameter description, please refer to the connect() method.

Parameters
fractionalSecondsPartThe number of fractional units (0 to 6). A value of -1 indicates that the fractional part is not stored. Fractional seconds part are supported for MySQL 5.6.4 http://dev.mysql.com/doc/refman/5.6/en/fractional-seconds.html

◆ MySQL() [2/2]

Wt::Dbo::backend::MySQL::MySQL ( const MySQL other)

Copies a MySQL connection.

This creates a new connection with the same settings as another connection.

See also
clone()

◆ ~MySQL()

Wt::Dbo::backend::MySQL::~MySQL ( )

Destructor.

Closes the connection.

Member Function Documentation

◆ alterTableConstraintString()

const char * Wt::Dbo::backend::MySQL::alterTableConstraintString ( ) const
virtual

Returns the supported fractional seconds part.

By default return -1: fractional part is not stored. Fractional seconds part is supported for MySQL 5.6.4 http://dev.mysql.com/doc/refman/5.6/en/fractional-seconds.html

See also
setFractionalSecondsPart()

Reimplemented from Wt::Dbo::SqlConnection.

◆ autoincrementCreateSequenceSql()

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

Returns the supported fractional seconds part.

By default return -1: fractional part is not stored. Fractional seconds part is supported for MySQL 5.6.4 http://dev.mysql.com/doc/refman/5.6/en/fractional-seconds.html

See also
setFractionalSecondsPart()

Implements Wt::Dbo::SqlConnection.

◆ autoincrementDropSequenceSql()

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

Returns the supported fractional seconds part.

By default return -1: fractional part is not stored. Fractional seconds part is supported for MySQL 5.6.4 http://dev.mysql.com/doc/refman/5.6/en/fractional-seconds.html

See also
setFractionalSecondsPart()

Implements Wt::Dbo::SqlConnection.

◆ autoincrementInsertSuffix()

std::string Wt::Dbo::backend::MySQL::autoincrementInsertSuffix ( const std::string &  id) const
virtual

Returns the supported fractional seconds part.

By default return -1: fractional part is not stored. Fractional seconds part is supported for MySQL 5.6.4 http://dev.mysql.com/doc/refman/5.6/en/fractional-seconds.html

See also
setFractionalSecondsPart()

Implements Wt::Dbo::SqlConnection.

◆ autoincrementSql()

std::string Wt::Dbo::backend::MySQL::autoincrementSql ( ) const
virtual

Returns the supported fractional seconds part.

By default return -1: fractional part is not stored. Fractional seconds part is supported for MySQL 5.6.4 http://dev.mysql.com/doc/refman/5.6/en/fractional-seconds.html

See also
setFractionalSecondsPart()

Implements Wt::Dbo::SqlConnection.

◆ autoincrementType()

std::string Wt::Dbo::backend::MySQL::autoincrementType ( ) const
virtual

Returns the supported fractional seconds part.

By default return -1: fractional part is not stored. Fractional seconds part is supported for MySQL 5.6.4 http://dev.mysql.com/doc/refman/5.6/en/fractional-seconds.html

See also
setFractionalSecondsPart()

Implements Wt::Dbo::SqlConnection.

◆ blobType()

const char * Wt::Dbo::backend::MySQL::blobType ( ) const
virtual

Returns the supported fractional seconds part.

By default return -1: fractional part is not stored. Fractional seconds part is supported for MySQL 5.6.4 http://dev.mysql.com/doc/refman/5.6/en/fractional-seconds.html

See also
setFractionalSecondsPart()

Implements Wt::Dbo::SqlConnection.

◆ commitTransaction()

void Wt::Dbo::backend::MySQL::commitTransaction ( )
virtual

Commits a transaction.

This function commits a transaction.

Implements Wt::Dbo::SqlConnection.

◆ connect()

bool Wt::Dbo::backend::MySQL::connect ( const std::string &  db,
const std::string &  dbuser = "root",
const std::string &  dbpasswd = "",
const std::string &  dbhost = "localhost",
unsigned int  dbport = 0,
const std::string &  dbsocket = "/var/run/mysqld/mysqld.sock" 
)

Tries to connect.

Parameters
dbThe database name.
dbuserThe username for the database connection - defaults to "root".
dbpasswdThe password for the database conection - defaults to an empty string.
dbhostThe hostname of the database - defaults to localhost.
dbportThe portnumber - defaults to a default port.
dbsocketThe socket to use.

Throws an exception if there was a problem, otherwise true.

◆ dateTimeType()

const char * Wt::Dbo::backend::MySQL::dateTimeType ( SqlDateTimeType  type) const
virtual

Returns the supported fractional seconds part.

By default return -1: fractional part is not stored. Fractional seconds part is supported for MySQL 5.6.4 http://dev.mysql.com/doc/refman/5.6/en/fractional-seconds.html

See also
setFractionalSecondsPart()

Implements Wt::Dbo::SqlConnection.

◆ executeSql()

void Wt::Dbo::backend::MySQL::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 from Wt::Dbo::SqlConnection.

◆ getFractionalSecondsPart()

int Wt::Dbo::backend::MySQL::getFractionalSecondsPart ( ) const

Returns the supported fractional seconds part.

By default return -1: fractional part is not stored. Fractional seconds part is supported for MySQL 5.6.4 http://dev.mysql.com/doc/refman/5.6/en/fractional-seconds.html

See also
setFractionalSecondsPart()

◆ init()

void Wt::Dbo::backend::MySQL::init ( )
private

Returns the supported fractional seconds part.

By default return -1: fractional part is not stored. Fractional seconds part is supported for MySQL 5.6.4 http://dev.mysql.com/doc/refman/5.6/en/fractional-seconds.html

See also
setFractionalSecondsPart()

◆ prepareStatement()

SqlStatement * Wt::Dbo::backend::MySQL::prepareStatement ( const std::string &  sql)
virtual

Prepares a statement.

Returns the prepared statement.

Implements Wt::Dbo::SqlConnection.

◆ requireSubqueryAlias()

virtual bool Wt::Dbo::backend::MySQL::requireSubqueryAlias ( ) const
virtual

Returns the supported fractional seconds part.

By default return -1: fractional part is not stored. Fractional seconds part is supported for MySQL 5.6.4 http://dev.mysql.com/doc/refman/5.6/en/fractional-seconds.html

See also
setFractionalSecondsPart()

Reimplemented from Wt::Dbo::SqlConnection.

◆ rollbackTransaction()

void Wt::Dbo::backend::MySQL::rollbackTransaction ( )
virtual

Rolls back a transaction.

This function rolls back a transaction.

Implements Wt::Dbo::SqlConnection.

◆ setFractionalSecondsPart()

void Wt::Dbo::backend::MySQL::setFractionalSecondsPart ( int  fractionalSecondsPart)

Set the supported fractional seconds part.

The fractional seconds part can be also set in the constructor Fractional seconds part is supported for MySQL 5.6.4 http://dev.mysql.com/doc/refman/5.6/en/fractional-seconds.html

Parameters
fractionalSecondsPartMust be in the range 0 to 6.
See also
setFractionalSecondsPart()

◆ startTransaction()

void Wt::Dbo::backend::MySQL::startTransaction ( )
virtual

Starts a transaction.

This function starts a transaction.

Implements Wt::Dbo::SqlConnection.

◆ supportAlterTable()

bool Wt::Dbo::backend::MySQL::supportAlterTable ( ) const
virtual

Returns the supported fractional seconds part.

By default return -1: fractional part is not stored. Fractional seconds part is supported for MySQL 5.6.4 http://dev.mysql.com/doc/refman/5.6/en/fractional-seconds.html

See also
setFractionalSecondsPart()

Reimplemented from Wt::Dbo::SqlConnection.

Member Data Documentation

◆ dateType_

std::string Wt::Dbo::backend::MySQL::dateType_
private

Returns the supported fractional seconds part.

By default return -1: fractional part is not stored. Fractional seconds part is supported for MySQL 5.6.4 http://dev.mysql.com/doc/refman/5.6/en/fractional-seconds.html

See also
setFractionalSecondsPart()

◆ dbhost_

std::string Wt::Dbo::backend::MySQL::dbhost_
private

Returns the supported fractional seconds part.

By default return -1: fractional part is not stored. Fractional seconds part is supported for MySQL 5.6.4 http://dev.mysql.com/doc/refman/5.6/en/fractional-seconds.html

See also
setFractionalSecondsPart()

◆ dbname_

std::string Wt::Dbo::backend::MySQL::dbname_
private

Returns the supported fractional seconds part.

By default return -1: fractional part is not stored. Fractional seconds part is supported for MySQL 5.6.4 http://dev.mysql.com/doc/refman/5.6/en/fractional-seconds.html

See also
setFractionalSecondsPart()

◆ dbpasswd_

std::string Wt::Dbo::backend::MySQL::dbpasswd_
private

Returns the supported fractional seconds part.

By default return -1: fractional part is not stored. Fractional seconds part is supported for MySQL 5.6.4 http://dev.mysql.com/doc/refman/5.6/en/fractional-seconds.html

See also
setFractionalSecondsPart()

◆ dbport_

unsigned int Wt::Dbo::backend::MySQL::dbport_
private

Returns the supported fractional seconds part.

By default return -1: fractional part is not stored. Fractional seconds part is supported for MySQL 5.6.4 http://dev.mysql.com/doc/refman/5.6/en/fractional-seconds.html

See also
setFractionalSecondsPart()

◆ dbsocket_

std::string Wt::Dbo::backend::MySQL::dbsocket_
private

Returns the supported fractional seconds part.

By default return -1: fractional part is not stored. Fractional seconds part is supported for MySQL 5.6.4 http://dev.mysql.com/doc/refman/5.6/en/fractional-seconds.html

See also
setFractionalSecondsPart()

◆ dbuser_

std::string Wt::Dbo::backend::MySQL::dbuser_
private

Returns the supported fractional seconds part.

By default return -1: fractional part is not stored. Fractional seconds part is supported for MySQL 5.6.4 http://dev.mysql.com/doc/refman/5.6/en/fractional-seconds.html

See also
setFractionalSecondsPart()

◆ fractionalSecondsPart_

int Wt::Dbo::backend::MySQL::fractionalSecondsPart_
private

Returns the supported fractional seconds part.

By default return -1: fractional part is not stored. Fractional seconds part is supported for MySQL 5.6.4 http://dev.mysql.com/doc/refman/5.6/en/fractional-seconds.html

See also
setFractionalSecondsPart()

◆ impl_

MySQL_impl* Wt::Dbo::backend::MySQL::impl_
private

Returns the supported fractional seconds part.

By default return -1: fractional part is not stored. Fractional seconds part is supported for MySQL 5.6.4 http://dev.mysql.com/doc/refman/5.6/en/fractional-seconds.html

See also
setFractionalSecondsPart()

◆ timeType_

std::string Wt::Dbo::backend::MySQL::timeType_
private

Returns the supported fractional seconds part.

By default return -1: fractional part is not stored. Fractional seconds part is supported for MySQL 5.6.4 http://dev.mysql.com/doc/refman/5.6/en/fractional-seconds.html

See also
setFractionalSecondsPart()

Generated on Fri May 17 2024 for the C++ Web Toolkit (Wt) by doxygen 1.9.8