Connection to a MySQL database.
More...
#include <mysql.hpp>
List of all members.
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) |
| ~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") |
void | getFoundRows (unsigned long long *const &rows, const unsigned int id) |
MYSQL & | connection (unsigned int id) |
void | commit (const unsigned int thread=0) |
void | rollback (const unsigned int thread=0) |
int | queriesSize () const |
| Returns the number of queued queries.
|
void | start () |
| Start all threads of the handler.
|
void | terminate () |
| Terminate all thread of the handler.
|
void | queue (Transaction< MySQL::Statement > &transaction, int instance) |
| Queue up a transaction for completion.
|
void | queue (MySQL::Statement *const &statement, QueryPar &query, int instance) |
int | threads () const |
| Returns the number of threads.
|
bool | running () const |
| Return true if the handler is running.
|
Static Public Attributes |
static const bool | s_false |
Detailed Description
Connection to a MySQL database.
Definition at line 41 of file mysql.hpp.
Constructor & Destructor Documentation
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.
- Parameters:
-
[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 76 of file mysql.hpp.
References connect().
ASql::MySQL::Connection::Connection |
( |
const int |
threads_ = 1 | ) |
|
|
inline |
! Incomplete Constructor
- Parameters:
-
[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.
Definition at line 87 of file mysql.hpp.
ASql::MySQL::Connection::~Connection |
( |
| ) |
|
Member Function Documentation
void ASql::MySQL::Connection::commit |
( |
const unsigned int |
thread = 0 | ) |
|
|
inlinevirtual |
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.
- Parameters:
-
[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 26 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 |
void ASql::MySQL::Connection::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.
- Parameters:
-
rows | A reference to a pointer to the integer to write the value to. |
Definition at line 78 of file mysql.cpp.
Returns the number of queued queries.
Queue up a transaction for completion.
void ASql::MySQL::Connection::rollback |
( |
const unsigned int |
thread = 0 | ) |
|
|
inlinevirtual |
bool ASql::Connection::running |
( |
| ) |
const |
|
inlineinherited |
Start all threads of the handler.
Terminate all thread of the handler.
int ASql::Connection::threads |
( |
| ) |
const |
|
inlineinherited |
Member Data Documentation
boost::scoped_array<MYSQL_BIND> ASql::MySQL::Connection::foundRowsBinding |
|
private |
! Bind object for storing the total number of results from a query.
Definition at line 57 of file mysql.hpp.
Referenced by connect().
boost::scoped_array<MYSQL_STMT*> ASql::MySQL::Connection::foundRowsStatement |
|
private |
! Pointer to the statement used to return the number of rows found.
Definition at line 52 of file mysql.hpp.
Referenced by connect().
boost::scoped_array<MYSQL> ASql::MySQL::Connection::m_connection |
|
private |
bool ASql::MySQL::Connection::m_initialized |
|
private |
int ASql::Connection::m_threads |
|
protectedinherited |
const int ASql::Connection::maxThreads |
|
protectedinherited |
bool ASql::Connection::terminateBool |
|
protectedinherited |
boost::mutex ASql::Connection::terminateMutex |
|
protectedinherited |
boost::condition_variable ASql::Connection::threadsChanged |
|
protectedinherited |
boost::mutex ASql::Connection::threadsMutex |
|
protectedinherited |
boost::scoped_array<boost::condition_variable> ASql::Connection::wakeUp |
|
protectedinherited |
The documentation for this class was generated from the following files: