#include <connection.h>
Inheritance diagram for mysqlpp::Connection:
Public Types | |
enum | OptionArgType |
Legal types of option arguments. | |
enum | Option |
Per-connection options you can set with set_option(). More... | |
Public Methods | |
MYSQLPP_EXPORT | Connection (bool te=true) |
Create object without connecting it to the MySQL server. | |
MYSQLPP_EXPORT | Connection (const char *db, const char *host="", const char *user="", const char *passwd="", uint port=0, my_bool compress=0, unsigned int connect_timeout=60, cchar *socket_name=0, unsigned int client_flag=0) |
Create object and connect to database server in one step. | |
MYSQLPP_EXPORT | ~Connection () |
Destroy connection object. | |
MYSQLPP_EXPORT bool | connect (cchar *db="", cchar *host="", cchar *user="", cchar *passwd="", uint port=0, my_bool compress=0, unsigned int connect_timeout=60, cchar *socket_name=0, unsigned int client_flag=0) |
Connect to database after object is created. | |
void | close () |
Close connection to MySQL server. | |
MYSQLPP_EXPORT std::string | info () |
Calls MySQL C API function mysql_info() and returns result as a C++ string. | |
bool | connected () const |
return true if connection was established successfully | |
bool | success () const |
Return true if the last query was successful. | |
void | purge () |
Alias for close(). | |
MYSQLPP_EXPORT Query | query () |
Return a new query object. | |
operator bool () | |
Alias for success(). | |
const char * | error () |
Return error message for last MySQL error associated with this connection. | |
int | errnum () |
Return last MySQL error number associated with this connection. | |
int | refresh (unsigned int refresh_options) |
Wraps MySQL C API function mysql_refresh() . | |
int | ping () |
"Pings" the MySQL database | |
int | kill (unsigned long pid) |
Kill a MySQL server thread. | |
std::string | client_info () |
Get MySQL client library version. | |
std::string | host_info () |
Get information about the network connection. | |
int | proto_info () |
Returns version number of MySQL protocol this connection is using. | |
std::string | server_info () |
Get the MySQL server's version number. | |
std::string | stat () |
Returns information about MySQL server status. | |
MYSQLPP_EXPORT bool | create_db (const std::string &db) |
Create a database. | |
MYSQLPP_EXPORT bool | drop_db (const std::string &db) |
Drop a database. | |
bool | select_db (const std::string &db) |
Change to a different database. | |
MYSQLPP_EXPORT bool | select_db (const char *db) |
Change to a different database. | |
MYSQLPP_EXPORT bool | reload () |
Ask MySQL server to reload the grant tables. | |
MYSQLPP_EXPORT bool | shutdown () |
Ask MySQL server to shut down. | |
st_mysql_options | get_options () const |
Return the connection options object. | |
MYSQLPP_EXPORT bool | set_option (Option option) |
Sets a connection option, with no argument. | |
MYSQLPP_EXPORT bool | set_option (Option option, const char *arg) |
Sets a connection option, with string argument. | |
MYSQLPP_EXPORT bool | set_option (Option option, unsigned int arg) |
Sets a connection option, with integer argument. | |
MYSQLPP_EXPORT bool | set_option (Option option, bool arg) |
Sets a connection option, with Boolean argument. | |
MYSQLPP_EXPORT void | enable_ssl (const char *key=0, const char *cert=0, const char *ca=0, const char *capath=0, const char *cipher=0) |
Enable SSL-encrypted connection. | |
my_ulonglong | affected_rows () |
Return the number of rows affected by the last query. | |
my_ulonglong | insert_id () |
Get ID generated for an AUTO_INCREMENT column in the previous INSERT query. | |
std::ostream & | api_version (std::ostream &os) |
Insert C API version we're linked against into C++ stream. | |
Protected Methods | |
MYSQLPP_EXPORT void | disconnect () |
Drop the connection to the database server. | |
bool | option_pending (Option option, bool arg) const |
Returns true if the given option is to be set once connection comes up. | |
void | apply_pending_options () |
For each option in pending option queue, call set_option(). | |
bool | bad_option (Option option, OptionArgType type) |
Generic wrapper for bad_option_*(). | |
bool | bad_option_type (Option option) |
Handles call of incorrect set_option() overload. | |
bool | bad_option_value (Option option) |
Handles bad option values sent to set_option(). | |
OptionArgType | option_arg_type (Option option) |
Given option value, return its proper argument type. | |
bool | set_option_impl (mysql_option moption, const void *arg=0) |
Set MySQL C API connection option. |
|
Per-connection options you can set with set_option().
This is currently a combination of the MySQL C API |
|
Create object without connecting it to the MySQL server.
|
|
Create object and connect to database server in one step.
This constructor allows you to most fully specify the options used when connecting to the MySQL database. It is the thinnest layer in MySQL++ over the MySQL C API function
|
|
Return the number of rows affected by the last query.
Simply wraps |
|
Insert C API version we're linked against into C++ stream. Version will be of the form X.Y.Z, where X is the major version number, Y the minor version, and Z the bug fix number. |
|
For each option in pending option queue, call set_option(). Called within connect() method after connection is established. Despools options in the order given to set_option(). |
|
Get MySQL client library version.
Simply wraps |
|
Close connection to MySQL server. Closes the connection to the MySQL server. |
|
Connect to database after object is created. It's better to use the connect-on-create constructor if you can. See its documentation for the meaning of these parameters. If you call this method on an object that is already connected to a database server, the previous connection is dropped and a new connection is established. |
|
return true if connection was established successfully
|
|
Create a database.
|
|
Drop the connection to the database server. This method is protected because it should only be used within the library. Unless you use the default constructor, this object should always be connected. |
|
Drop a database.
|
|
Enable SSL-encrypted connection.
Wraps |
|
Return last MySQL error number associated with this connection.
Simply wraps |
|
Return error message for last MySQL error associated with this connection.
Simply wraps |
|
Get information about the network connection. String contains info about type of connection and the server hostname.
Simply wraps |
|
Get ID generated for an AUTO_INCREMENT column in the previous INSERT query.
|
|
Kill a MySQL server thread.
mysql_kill() in the C API. |
|
Alias for success(). Alias for success() member function. Allows you to have code constructs like this:
Connection conn; .... use conn if (conn) { ... last SQL query was successful } else { ... error occurred in SQL query } |
|
Returns true if the given option is to be set once connection comes up.
|
|
"Pings" the MySQL database If server doesn't respond, this function tries to reconnect.
mysql_ping() in the C API. |
|
Returns version number of MySQL protocol this connection is using.
Simply wraps |
|
Return a new query object. The returned query object is tied to this MySQL connection, so when you call a method like execute() on that object, the query is sent to the server this object is connected to. |
|
Wraps MySQL C API function
The corresponding C API function is undocumented. All I know is that it's used by |
|
Ask MySQL server to reload the grant tables. User must have the "reload" privilege.
Simply wraps |
|
Get the MySQL server's version number.
Simply wraps |
|
Sets a connection option, with no argument.
mysql_options() or mysql_set_server_option() in the C API.
There are several overloaded versions of this function. The others take an additional argument for the option and differ only by the type of the option. Unlike with the underlying C API, it does matter which of these overloads you call: if you use the wrong argument type or pass an argument where one is not expected (or vice versa), the call will either throw an exception or return false, depending on the object's "throw exceptions" flag. This mechanism parallels the underlying C API structure fairly closely, but do not expect this to continue in the future. Its very purpose is to 'paper over' the differences among the C API's option setting mechanisms, so it may become further abstracted from these mechanisms.
|
|
Set MySQL C API connection option.
Wraps |
|
Ask MySQL server to shut down. User must have the "shutdown" privilege.
Simply wraps |
|
Returns information about MySQL server status.
String is similar to that returned by the |