#include <conn.h>
Public Member Functions | |
Conn () | |
Default constructor. | |
Conn (char const *host, char const *user, char const *password, char const *db, unsigned int port, char const *us) | |
Constructor with the same parameters as mysql_connect(). | |
Conn (Conn const &c) | |
Copy constructor. | |
Conn & | operator= (Conn const &right) |
Assignment operator. | |
~Conn () | |
Destructor. | |
bool | connect () |
Connects to the MySQL server. | |
bool | change_user (char const *user, char const *password, char const *db) |
Changes the current MySQL user. | |
bool | select_db (char const *db) |
Changes the current MySQL database. | |
bool | reconnect () |
Reconnects to the MySQL server. | |
bool | ping () |
"Pings" the MySQL server. | |
void | close () |
Closes the connection to the MySQL server. | |
unsigned long | escape_string (misc::cstring &dest, char const *src, long len=-1) |
Escapes a string. | |
char const * | escape_string (char const *str, long len=-1) |
Escapes a string. | |
bool | query (char const *query, unsigned long length, Result *result, bool use=false) |
Executes a query. | |
bool | query (char const *query, Result *result, bool use=false) |
Same as query(query, strlen(query), result, use);. | |
bool | queryf (Result *result, char const *fmt,...) FORMAT(printf |
printf()-like interface to query() -- limited to queries with 16384 characters. | |
bool bool | connected () const |
Returns whether the MySQL connection is established. | |
bool | gone () const |
Returns whether the server is gone or lost. | |
unsigned int | queries () const |
Returns the number of queries that have been issued since connection. | |
time_t | since () const |
Returns when the connection was established. | |
double | exectime () const |
Returns the execution time for the last query. | |
unsigned long | thread_id () |
Returns the MySQL connection thread ID. | |
unsigned int | errnum () |
Returns the last error number that happened on the mysql connection. | |
char const * | error () |
Returns a string describing the last error that happened on the mysql connection. | |
char const * | host_info () |
Returns a string describing the connection, including server hostname. | |
unsigned int | proto_info () |
Returns the protocol version used by the connection. | |
char const * | server_info () |
Returns a string that represents the server version number. | |
unsigned long | server_version () |
Returns the version number of the server. | |
char const * | stat () |
Returns server status string. | |
my_ulonglong | insert_id () |
Returns the last insert ID. | |
my_ulonglong | affected_rows () |
Returns the number of rows affected by the last query. | |
unsigned int | warning_count () |
Returns the number of warnings for the last query. | |
char const * | info () |
Returns information about the last query. | |
unsigned int | field_count () |
Returns the number of fields for the last query. | |
unsigned int | connect_timeout () const |
Returns the connection timeout (in seconds). | |
unsigned int | connect_timeout (unsigned int timeout) |
Sets the connection timeout (in seconds). | |
my_bool | reconnect () const |
Returns whether the connection is reestablished automatically. | |
my_bool | reconnect (my_bool reco) |
Sets whether the connection is reestablished automatically. | |
char const * | host () const |
Returns the MySQL hostname. | |
char const * | host (char const *host) |
Sets the MySQL hostname. | |
unsigned int | port () const |
Returns the MySQL port. | |
unsigned int | port (unsigned int port) |
Sets the MySQL port. | |
char const * | unix_socket () const |
Returns the MySQL hostname. | |
char const * | unix_socket (char const *us) |
Sets the MySQL hostname. | |
char const * | user () const |
Returns the MySQL username. | |
char const * | user (char const *user) |
Sets the MySQL username. | |
char const * | password () const |
Returns the MySQL password. | |
char const * | password (char const *password) |
Sets the MySQL username. | |
char const * | db () const |
Returns the MySQL database. | |
char const * | db (char const *db) |
Sets the MySQL database. | |
char const * | charset () |
Returns the connection character set. | |
char const * | charset (char const *charset) |
Sets the connection character set. | |
Events const * | events () const |
Returns the event notifier object. | |
Events * | events (Events *events) |
Sets the event notifier object. | |
bool | log_queries () const |
Returns whether queries are logged. | |
bool | log_queries (bool value) |
Sets whether queries are logged. | |
bool | log_warnings () const |
Returns whether warnings are logged. | |
bool | log_warnings (bool value) |
Sets whether warnings are logged. | |
Static Public Member Functions | |
static char const * | client_info () |
Returns the MySQL client library version string. | |
static unsigned long | client_version () |
Returns the MySQL client library version. | |
Protected Attributes | |
MYSQL * | m_handle |
The MySQL connection handle. | |
bool | m_connected |
Is it currently connected? | |
bool | m_gone |
Is the server lost or gone away? | |
unsigned int | m_queries |
How much queries have been done? | |
time_t | m_since |
Since when are we connected? | |
double | m_exectime |
Last query execution time. | |
unsigned int | m_ctimeout |
Connect timeout (in seconds). | |
my_bool | m_reconnect |
Reconnect automatically ? | |
misc::cstring | m_host |
Server's hostname. | |
unsigned int | m_port |
Server's port. | |
misc::cstring | m_unixsocket |
Server's unix socket. | |
misc::cstring | m_user |
MySQL username. | |
misc::cstring | m_password |
MySQL password. | |
misc::cstring | m_db |
MySQL database. | |
misc::cstring | m_charset |
Connection character set. | |
misc::cstring | m_es |
A shared buffer for escape_string(). | |
size_t | m_essize |
Maximum size of the escape_string buffer. | |
Events * | m_e |
Events notifier. | |
bool | m_logqueries |
Log queries? | |
bool | m_logwarnings |
Log warnings? |
See the MySQL C API for more detailed information on some of the functions.
|
Copy constructor. It copies the various data fields of the connection (like host, username, password...) but does not reestablish a connection.
|
|
Changes the current MySQL user. If the user, password or database is invalid, then no change is made and the connection is still valid. Else, the user(), password() and db() fields are updated automatically.
|
|
Closes the connection to the MySQL server, if a connection is established. An evClosed event is logged. |
|
Connects to the MySQL server.
|
|
Sets the connection timeout (in seconds).
|
|
Returns the connection timeout (in seconds).
|
|
Escapes a string in a way that is suitable to use in a query. The returned string is stored in the object instance for which the method is called; therefore, further calls to this method for the same object will overwrite the contents of the returned string.
|
|
Escapes a string in a way that is suitable to use in a query.
|
|
Sets the event notifier object.
|
|
Returns whether the server is gone or lost (i.e. if one of the MySQL functions returned CR_SERVER_GONE_ERROR or CR_SERVER_LOST), if the connection has not been reestablished.
|
|
Returns information about the last query, but only for a few statements, including INSERT, ALTER TABLE and UPDATE.
|
|
Sets whether warnings are logged. Warnings may only be logged after a call to the execute() method.
|
|
Assignment operator. Like the copy constructor, a new connection is not established.
|
|
"Pings" the MySQL server, i.e. checks whether the connection is working. If the connection has gone down, a reconnection is attempted.
|
|
Executes a SQL query.
|
|
Sets whether the connection is reestablished automatically if it was dropped and a query is made.
|
|
Returns whether the connection is reestablished automatically if it was dropped and a query is made.
|
|
Reconnects to the MySQL server. This is equivalent to calling close() and connect().
|
|
Changes the current MySQL database. If the database can't be changed, then no change is made and the connection is still valid. Else, the db() field is updated automatically.
|