![]() |
AnCH Framework
0.1
Another C++ Hack Framework
|
SQL connection virtual class. More...
#include <connection.hpp>
Public Member Functions | |
| Connection () throw (SqlException) | |
| Connection (const Connection &)=delete | |
| virtual | ~Connection () |
| void | commit () throw (SqlException) |
| void | rollback () throw (SqlException) |
| void | setAutoCommit (bool autoCommit) throw (SqlException) |
| ResultSet * | query (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 ResultSet * | executeQuery (const std::string &query)=0 throw (SqlException) |
| virtual uint64_t | executeUpdate (const std::string &query)=0 throw (SqlException) |
| virtual void | sendCommit ()=0 throw (SqlException) |
| virtual void | sendRollback ()=0 throw (SqlException) |
| virtual void | toggleAutoCommit (bool autoCommit)=0 throw (SqlException) |
| void | setValid (bool valid) |
Protected Attributes | |
| bool | _autoCommit |
| bool | _valid |
SQL connection virtual class.
Abstract layer for SQL connections management.
| Connection::Connection | ( | ) | ||
| throw | ( | SqlException | ||
| ) | ||||
Connection default constructor
| SqlException | any error |
|
delete |
Prohibit Connection copy constructor
|
virtual |
Connection destrcutor
| void Connection::commit | ( | ) | ||
| throw | ( | SqlException | ||
| ) | ||||
Commit current SQL transaction.
If auto commit is set, this method does nothing.
| SqlException | any error |
|
protectedpure virtual | ||||||||||||||
Execute SQL select query
| query | the SQL query to execute |
| SqlException | any error |
Implemented in anch::sql::PostgreSQLConnection, anch::sql::MySQLConnection, and anch::sql::SQLite3Connection.
|
protectedpure virtual | ||||||||||||||
Execute SQL update query
| query | the SQL query to execute |
| SqlException | any error |
Implemented in anch::sql::PostgreSQLConnection, anch::sql::MySQLConnection, and anch::sql::SQLite3Connection.
|
inline |
Auto commit status getter
|
inline |
Valid status getter
| ResultSet * Connection::query | ( | const std::string & | query | ) | |
| throw | ( | SqlException | |||
| ) | |||||
Execute SQL query
| query | the SQL query to execute |
| SqlException | any error |
| void Connection::queryExtract | ( | const std::string & | sqlQuery, |
| std::function< void(ResultSet &)> | resExtractor | ||
| ) | |||
| throw | ( | SqlException | |
| ) | |||
Execute query and extract result set
| sqlQuery | the SQL query to execute |
| resExtractor | the result set extractor function |
| SqlException | any error |
| void Connection::queryMapRow | ( | const std::string & | sqlQuery, |
| std::function< void(ResultSet &)> | rowMapper | ||
| ) | |||
| throw | ( | SqlException | |
| ) | |||
Execute query and treat each row of result set
| sqlQuery | the SQL query to execute |
| rowMapper | the row mapper function |
| SqlException | any error |
| void Connection::rollback | ( | ) | ||
| throw | ( | SqlException | ||
| ) | ||||
Rollback current SQL transaction.
If auto commit is set, this method does nothing.
| SqlException | any error |
|
protectedpure virtual | |||||||||||||
Send commit to database server
| SqlException | any error |
Implemented in anch::sql::PostgreSQLConnection, anch::sql::MySQLConnection, and anch::sql::SQLite3Connection.
|
protectedpure virtual | |||||||||||||
Send rollback to database server
| SqlException | any error |
Implemented in anch::sql::PostgreSQLConnection, anch::sql::MySQLConnection, and anch::sql::SQLite3Connection.
| void Connection::setAutoCommit | ( | bool | autoCommit | ) | |
| throw | ( | SqlException | |||
| ) | |||||
Auto commit status setter.
Change auto commit status in database connection too.
This method does nothing if auto commit is same as before.
| autoCommit | the status |
| SqlException | any error |
|
inlineprotected |
Valid status setter
| valid | the status to set |
|
protectedpure virtual | ||||||||||||||
Send auto commit status modification to server
| autoCommit | the status to send |
| SqlException | any error |
Implemented in anch::sql::PostgreSQLConnection, anch::sql::MySQLConnection, and anch::sql::SQLite3Connection.
| uint64_t Connection::update | ( | const std::string & | query | ) | |
| throw | ( | SqlException | |||
| ) | |||||
Execute update (INSERT, UPDATE or DELETE) SQL query.
| query | the SQL query |
| SqlException | any error |
|
protected |
Auto commit
|
protected |
Is SQL connection valid
1.8.11