Connection to a MySQL database. More...
#include <mysql.hpp>
Public Member Functions | |
Connection (const char *host, const char *user, const char *passwd, const char *db, unsigned int port, const char *unix_socket, unsigned long client_flag, const char *const charset="latin1", const int threads_=1) | |
Complete Constructor. | |
Connection (const int threads_=1) | |
Incomplete Constructor. | |
~Connection () | |
void | connect (const char *host, const char *user, const char *passwd, const char *db, unsigned int port, const char *unix_socket, unsigned long client_flag, const char *const charset="latin1") |
Connect to a MySQL server. | |
void | getFoundRows (unsigned long long *const &rows, const unsigned int id) |
Returns the number of rows found in the last query. Designed for use with SQL_CALC_FOUND_ROWS in the query itself. | |
MYSQL & | connection (unsigned int id) |
void | commit (const unsigned int thread=0) |
void | rollback (const unsigned int thread=0) |
Private Attributes | |
boost::scoped_array< MYSQL > | m_connection |
Actual MySQL C API connection object. | |
boost::scoped_array< MYSQL_STMT * > | foundRowsStatement |
Pointer to the statement used to return the number of rows found. | |
boost::scoped_array< MYSQL_BIND > | foundRowsBinding |
Bind object for storing the total number of results from a query. | |
bool | m_initialized |
Connection to a MySQL database.
Definition at line 42 of file mysql.hpp.
ASql::MySQL::Connection::Connection | ( | const char * | host, |
const char * | user, | ||
const char * | passwd, | ||
const char * | db, | ||
unsigned int | port, | ||
const char * | unix_socket, | ||
unsigned long | client_flag, | ||
const char *const | charset = "latin1" , |
||
const int | threads_ = 1 |
||
) | [inline] |
Complete Constructor.
[in] | host | The value of host may be either a hostname or an IP address. If host is NULL or the string "localhost", a connection to the local host is assumed. For Windows, the client connects using a shared-memory connection, if the server has shared-memory connections enabled. Otherwise, TCP/IP is used. For Unix, the client connects using a Unix socket file. |
[in] | user | The user parameter contains the user's MySQL login ID. If user is NULL or the empty string "", the current user is assumed. Under Unix, this is the current login name. Under Windows ODBC, the current username must be specified explicitly. |
[in] | passwd | The passwd parameter contains the password for user. If passwd is NULL, only entries in the user table for the user that have a blank (empty) password field are checked for a match. This allows the database administrator to set up the MySQL privilege system in such a way that users get different privileges depending on whether they have specified a password. |
[in] | db | db is the database name. If db is not NULL, the connection sets the default database to this value. |
[in] | port | If port is not 0, the value is used as the port number for the TCP/IP connection. Note that the host parameter determines the type of the connection. |
[in] | unix_socket | If unix_socket is not NULL, the string specifies the socket or named pipe that should be used. Note that the host parameter determines the type of the connection. |
[in] | client_flag | The value of client_flag is usually 0, but can be set to a combination of the following flags to enable certain features. See the mysql c api reference manual for more details. |
[in] | charset | Null terminated string representation of desired connection character set (latin1, utf8, ...) |
[in] | threads_ | Number of threads to have for simultaneous queries. The higher this number is the more concurrent SQL requeries can be processed. |
Definition at line 77 of file mysql.hpp.
References connect().
ASql::MySQL::Connection::Connection | ( | const int | threads_ = 1 ) |
[inline] |
Incomplete Constructor.
[in] | threads_ | Number of threads to have for simultaneous queries. The higher this number is the more concurrent SQL requeries can be processed. |
Reimplemented from ASql::Connection.
void ASql::MySQL::Connection::commit | ( | const unsigned int | thread = 0 ) |
[inline, virtual] |
void ASql::MySQL::Connection::connect | ( | const char * | host, |
const char * | user, | ||
const char * | passwd, | ||
const char * | db, | ||
unsigned int | port, | ||
const char * | unix_socket, | ||
unsigned long | client_flag, | ||
const char *const | charset = "latin1" |
||
) |
Connect to a MySQL server.
[in] | host | The value of host may be either a hostname or an IP address. If host is NULL or the string "localhost", a connection to the local host is assumed. For Windows, the client connects using a shared-memory connection, if the server has shared-memory connections enabled. Otherwise, TCP/IP is used. For Unix, the client connects using a Unix socket file. |
[in] | user | The user parameter contains the user's MySQL login ID. If user is NULL or the empty string "", the current user is assumed. Under Unix, this is the current login name. Under Windows ODBC, the current username must be specified explicitly. |
[in] | passwd | The passwd parameter contains the password for user. If passwd is NULL, only entries in the user table for the user that have a blank (empty) password field are checked for a match. This allows the database administrator to set up the MySQL privilege system in such a way that users get different privileges depending on whether they have specified a password. |
[in] | db | db is the database name. If db is not NULL, the connection sets the default database to this value. |
[in] | port | If port is not 0, the value is used as the port number for the TCP/IP connection. Note that the host parameter determines the type of the connection. |
[in] | unix_socket | If unix_socket is not NULL, the string specifies the socket or named pipe that should be used. Note that the host parameter determines the type of the connection. |
[in] | client_flag | The value of client_flag is usually 0, but can be set to a combination of the following flags to enable certain features. See the mysql c api reference manual for more details. |
[in] | charset | Null terminated string representation of desired connection character set (latin1, utf8, ...) |
Definition at line 25 of file mysql.cpp.
References foundRowsBinding, foundRowsStatement, m_connection, m_initialized, and ASql::Connection::threads().
Referenced by Connection().
MYSQL& ASql::MySQL::Connection::connection | ( | unsigned int | id ) | [inline] |
Definition at line 117 of file mysql.hpp.
References m_connection.
void ASql::MySQL::Connection::getFoundRows | ( | unsigned long long *const & | rows, |
const unsigned int | id | ||
) |
void ASql::MySQL::Connection::rollback | ( | const unsigned int | thread = 0 ) |
[inline, virtual] |
boost::scoped_array<MYSQL_BIND> ASql::MySQL::Connection::foundRowsBinding [private] |
boost::scoped_array<MYSQL_STMT*> ASql::MySQL::Connection::foundRowsStatement [private] |
boost::scoped_array<MYSQL> ASql::MySQL::Connection::m_connection [private] |
Actual MySQL C API connection object.
Definition at line 48 of file mysql.hpp.
Referenced by commit(), connect(), connection(), and rollback().
bool ASql::MySQL::Connection::m_initialized [private] |