AnCH Framework  0.1
Another C++ Hack Framework
Public Member Functions | Protected Member Functions | List of all members
anch::sql::MySQLConnection Class Reference

MySQL connection. More...

#include <mysqlConnection.hpp>

Inheritance diagram for anch::sql::MySQLConnection:
Collaboration diagram for anch::sql::MySQLConnection:

Public Member Functions

 MySQLConnection (const std::string &host, const std::string &user, const std::string &password, const std::string &database, int port, const std::string &app="AnCH") throw (SqlException)
 
 MySQLConnection (const SqlConnectionConfiguration &config) throw (SqlException)
 
 MySQLConnection (const MySQLConnection &) throw (SqlException)
 
virtual ~MySQLConnection () noexcept
 
- Public Member Functions inherited from anch::sql::Connection
 Connection () throw (SqlException)
 
 Connection (const Connection &)=delete
 
virtual ~Connection ()
 
void commit () throw (SqlException)
 
void rollback () throw (SqlException)
 
void setAutoCommit (bool autoCommit) throw (SqlException)
 
ResultSetquery (const std::string &query) throw (SqlException)
 
void queryMapRow (const std::string &sqlQuery, std::function< void(ResultSet &)> rowMapper) throw (SqlException)
 
void queryExtract (const std::string &sqlQuery, std::function< void(ResultSet &)> resExtractor) throw (SqlException)
 
uint64_t update (const std::string &query) throw (SqlException)
 
bool isAutoCommit () const
 
bool isValid () const
 

Protected Member Functions

virtual ResultSetexecuteQuery (const std::string &query) override throw (SqlException)
 
virtual uint64_t executeUpdate (const std::string &query) override throw (SqlException)
 
virtual void sendCommit () override throw (SqlException)
 
virtual void sendRollback () override throw (SqlException)
 
virtual void toggleAutoCommit (bool autoCommit) override throw (SqlException)
 
- Protected Member Functions inherited from anch::sql::Connection
void setValid (bool valid)
 

Additional Inherited Members

- Protected Attributes inherited from anch::sql::Connection
bool _autoCommit
 
bool _valid
 

Detailed Description

MySQL connection.

SQL connection implementation through MySQL native library

Author
Vincent Lachenal
Since
0.1

Constructor & Destructor Documentation

MySQLConnection::MySQLConnection ( const std::string &  host,
const std::string &  user,
const std::string &  password,
const std::string &  database,
int  port,
const std::string &  app = "AnCH" 
)
throw (SqlException
)

MySQLConnection constructor

Parameters
hostthe MySQL server host
userthe connection user
passwordthe connection password
databasethe database name
portthe connection port
appthe client application (default: AnCH) ; used to retrieve configuration per application if declared in my.cnf
Exceptions
SqlExceptionany error
MySQLConnection::MySQLConnection ( const SqlConnectionConfiguration config)
throw (SqlException
)

MySQLConnection constructor

Parameters
configthe MySQL database configuration
Exceptions
SqlExceptionany error
anch::sql::MySQLConnection::MySQLConnection ( const MySQLConnection )
throw (SqlException
)

Prohibits MySQLConnection copy constructor

MySQLConnection::~MySQLConnection ( )
virtualnoexcept

MySQLConnection destructor

Member Function Documentation

ResultSet * MySQLConnection::executeQuery ( const std::string &  query)
throw (SqlException
)
overrideprotectedvirtual

Execute SQL select query

Parameters
querythe SQL query to execute
Returns
the result set
Exceptions
SqlExceptionany error

Implements anch::sql::Connection.

uint64_t MySQLConnection::executeUpdate ( const std::string &  query)
throw (SqlException
)
overrideprotectedvirtual

Execute SQL update query

Parameters
querythe SQL query to execute
Returns
the number of updated rows
Exceptions
SqlExceptionany error

Implements anch::sql::Connection.

void MySQLConnection::sendCommit ( )
throw (SqlException
)
overrideprotectedvirtual

Send commit to database server

Exceptions
SqlExceptionfail to commit transaction

Implements anch::sql::Connection.

void MySQLConnection::sendRollback ( )
throw (SqlException
)
overrideprotectedvirtual

Send rollback to database server

Exceptions
SqlExceptionfail to rollback transaction

Implements anch::sql::Connection.

void MySQLConnection::toggleAutoCommit ( bool  autoCommit)
throw (SqlException
)
overrideprotectedvirtual

Send auto commit status modification to server

Parameters
autoCommitthe status to send
Exceptions
SqlExceptionany error

Implements anch::sql::Connection.


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