AnCH Framework 0.1
Another C++ Hack Framework
 
Loading...
Searching...
No Matches
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 SqlConnectionConfiguration &config)
 
 MySQLConnection (const MySQLConnection &)
 
virtual ~MySQLConnection () noexcept
 
- Public Member Functions inherited from anch::sql::Connection
 Connection ()
 
 Connection (const Connection &)=delete
 
virtual ~Connection () noexcept
 
void startTransaction ()
 
void begin ()
 
void commit ()
 
void rollback ()
 
void release () noexcept
 
PreparedStatementprepareStatement (const std::string &query)
 
ResultSetquery (const std::string &query)
 
void queryMapRow (const std::string &sqlQuery, std::function< void(ResultSet &)> rowMapper)
 
void queryExtract (const std::string &sqlQuery, std::function< void(ResultSet &)> resExtractor)
 
template<typename T, typename... Q>
ResultSetquery (const std::string &query, const T &value, const Q &... values)
 
template<typename T, typename... Q>
void queryMapRow (const std::string &query, std::function< void(ResultSet &)> rowMapper, const T &value, const Q &... values)
 
template<typename T, typename... Q>
void queryExtract (const std::string &query, std::function< void(ResultSet &)> resExtractor, const T &value, const Q &... values)
 
uint64_t update (const std::string &query)
 
template<typename T, typename... Q>
uint64_t update (const std::string &query, const T &value, const Q &... values)
 
template<typename T, typename Iterable>
uint64_t batchUpdate (const std::string &query, std::function< void(PreparedStatement &, const T &)> mapper, const Iterable &values)
 
bool isValid () const noexcept
 

Protected Member Functions

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

Additional Inherited Members

- Protected Attributes inherited from anch::sql::Connection
bool _valid
 
bool _transaction
 
std::map< std::string, PreparedStatement * > _stmts
 
bool _errors
 

Detailed Description

MySQL connection.

SQL connection implementation through MySQL native library

Author
Vincent Lachenal
Since
0.1

Constructor & Destructor Documentation

◆ MySQLConnection() [1/2]

anch::sql::MySQLConnection::MySQLConnection ( const SqlConnectionConfiguration & config)

MySQLConnection constructor

Parameters
configthe MySQL database configuration
Exceptions
SqlExceptionany error

◆ MySQLConnection() [2/2]

anch::sql::MySQLConnection::MySQLConnection ( const MySQLConnection & )

Prohibits MySQLConnection copy constructor

+ Here is the call graph for this function:

◆ ~MySQLConnection()

virtual anch::sql::MySQLConnection::~MySQLConnection ( )
virtualnoexcept

MySQLConnection destructor

Member Function Documentation

◆ executeQuery()

virtual ResultSet * anch::sql::MySQLConnection::executeQuery ( const std::string & query)
overrideprotectedvirtual

Execute SQL select query

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

Implements anch::sql::Connection.

+ Here is the call graph for this function:

◆ executeUpdate()

virtual uint64_t anch::sql::MySQLConnection::executeUpdate ( const std::string & query)
overrideprotectedvirtual

Execute SQL update query

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

Implements anch::sql::Connection.

+ Here is the call graph for this function:

◆ makePrepared()

virtual PreparedStatement * anch::sql::MySQLConnection::makePrepared ( const std::string & query)
overrideprotectedvirtual

Send SQL query to prepare SQL statement

Parameters
querythe SQL query
Returns
the prepared statement
Exceptions
SqlExceptionany error

Implements anch::sql::Connection.

+ Here is the call graph for this function:

◆ sendCommit()

virtual void anch::sql::MySQLConnection::sendCommit ( )
overrideprotectedvirtual

Send commit to database server

Exceptions
SqlExceptionfail to commit transaction

Implements anch::sql::Connection.

+ Here is the call graph for this function:

◆ sendRollback()

virtual void anch::sql::MySQLConnection::sendRollback ( )
overrideprotectedvirtual

Send rollback to database server

Exceptions
SqlExceptionfail to rollback transaction

Implements anch::sql::Connection.

+ Here is the call graph for this function:

◆ sendStartTransaction()

virtual void anch::sql::MySQLConnection::sendStartTransaction ( )
overrideprotectedvirtual

Send start transaction to database server

Exceptions
SqlExceptionany error

Implements anch::sql::Connection.

+ Here is the call graph for this function:

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