fastcgi++
|
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) | |
~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 |
Protected Attributes | |
const int | maxThreads |
Number of threads to pool for simultaneous queries. | |
boost::mutex | threadsMutex |
boost::condition_variable | threadsChanged |
int | m_threads |
boost::scoped_array < boost::condition_variable > | wakeUp |
boost::mutex | terminateMutex |
bool | terminateBool |
Private Attributes | |
boost::scoped_array< MYSQL > | m_connection |
boost::scoped_array< MYSQL_STMT * > | foundRowsStatement |
boost::scoped_array< MYSQL_BIND > | foundRowsBinding |
bool | m_initialized |
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 76 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 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] |
Definition at line 116 of file mysql.hpp.
References m_connection.
void ASql::MySQL::Connection::getFoundRows | ( | unsigned long long *const & | rows, |
const unsigned int | id | ||
) |
int ASql::ConnectionPar< MySQL::Statement >::queriesSize | ( | ) | const [inherited] |
Returns the number of queued queries.
void ASql::ConnectionPar< MySQL::Statement >::queue | ( | Transaction< MySQL::Statement > & | transaction, |
int | instance | ||
) | [inherited] |
Queue up a transaction for completion.
void ASql::ConnectionPar< MySQL::Statement >::queue | ( | MySQL::Statement *const & | statement, |
QueryPar & | query, | ||
int | instance | ||
) | [inline, inherited] |
void ASql::MySQL::Connection::rollback | ( | const unsigned int | thread = 0 | ) | [inline, virtual] |
bool ASql::Connection::running | ( | ) | const [inline, inherited] |
Return true if the handler is running.
Definition at line 119 of file asql.hpp.
References ASql::Connection::m_threads.
void ASql::ConnectionPar< MySQL::Statement >::start | ( | ) | [inherited] |
Start all threads of the handler.
void ASql::ConnectionPar< MySQL::Statement >::terminate | ( | ) | [inherited] |
Terminate all thread of the handler.
int ASql::Connection::threads | ( | ) | const [inline, inherited] |
Returns the number of threads.
Definition at line 116 of file asql.hpp.
References ASql::Connection::maxThreads.
Referenced by connect().
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 47 of file mysql.hpp.
Referenced by commit(), connect(), connection(), and rollback().
bool ASql::MySQL::Connection::m_initialized [private] |
int ASql::Connection::m_threads [protected, inherited] |
Definition at line 127 of file asql.hpp.
Referenced by ASql::Connection::running().
const int ASql::Connection::maxThreads [protected, inherited] |
Number of threads to pool for simultaneous queries.
Definition at line 124 of file asql.hpp.
Referenced by ASql::Connection::threads().
const bool ASql::ConnectionPar< MySQL::Statement >::s_false [static, inherited] |
bool ASql::Connection::terminateBool [protected, inherited] |
boost::mutex ASql::Connection::terminateMutex [protected, inherited] |
boost::condition_variable ASql::Connection::threadsChanged [protected, inherited] |
boost::mutex ASql::Connection::threadsMutex [protected, inherited] |
boost::scoped_array<boost::condition_variable> ASql::Connection::wakeUp [protected, inherited] |