#include <dbdriver.h>
Public Types | |
enum | nr_code { nr_more_results, nr_last_result, nr_error, nr_not_supported } |
Result code returned by next_result(). More... | |
Public Member Functions | |
DBDriver () | |
Create object. | |
DBDriver (const DBDriver &other) | |
Duplicate an existing driver. | |
virtual | ~DBDriver () |
Destroy object. | |
ulonglong | affected_rows () |
Return the number of rows affected by the last query. | |
std::string | client_version () const |
Get database client library version. | |
bool | connect (const MYSQL &mysql) |
Establish a new connection using the same parameters as an existing connection. | |
virtual bool | connect (const char *host, const char *socket_name, unsigned int port, const char *db, const char *user, const char *password) |
Connect to database server. | |
bool | connected () const |
Return true if we have an active connection to the database server. | |
void | copy (const DBDriver &other) |
Establish a new connection as a copy of an existing one. | |
bool | create_db (const char *db) const |
Ask the database server to create a database. | |
void | data_seek (MYSQL_RES *res, ulonglong offset) const |
Seeks to a particualr row within the result set. | |
void | disconnect () |
Drop the connection to the database server. | |
bool | drop_db (const std::string &db) const |
Drop a database. | |
bool | 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. | |
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. | |
size_t | escape_string (char *to, const char *from, size_t length) |
SQL-escapes the given string, taking into account the. | |
bool | execute (const char *qstr, size_t length) |
Executes the given query string. | |
MYSQL_ROW | fetch_row (MYSQL_RES *res) const |
Returns the next raw C API row structure from the given result set. | |
const unsigned long * | fetch_lengths (MYSQL_RES *res) const |
Returns the lengths of the fields in the current row from a "use" query. | |
MYSQL_FIELD * | fetch_field (MYSQL_RES *res, size_t i=UINT_MAX) const |
Returns information about a particular field in a result set. | |
void | field_seek (MYSQL_RES *res, size_t field) const |
Jumps to the given field within the result set. | |
void | free_result (MYSQL_RES *res) const |
Releases memory used by a result set. | |
st_mysql_options | get_options () const |
Return the connection options object. | |
std::string | ipc_info () |
Get information about the IPC connection to the database server. | |
ulonglong | insert_id () |
Get ID generated for an AUTO_INCREMENT column in the previous INSERT query. | |
bool | kill (unsigned long tid) |
Kill a MySQL server thread. | |
bool | more_results () |
Returns true if there are unconsumed results from the most recent query. | |
nr_code | next_result () |
Moves to the next result set from a multi-query. | |
int | num_fields (MYSQL_RES *res) const |
Returns the number of fields in the given result set. | |
ulonglong | num_rows (MYSQL_RES *res) const |
Returns the number of rows in the given result set. | |
bool | ping () |
"Pings" the MySQL database | |
int | protocol_version () |
Returns version number of MySQL protocol this connection is using. | |
std::string | query_info () |
Returns information about the last executed query. | |
bool | refresh (unsigned options) |
Asks the database server to refresh certain internal data structures. | |
bool | result_empty () |
Returns true if the most recent result set was empty. | |
bool | select_db (const char *db) |
Asks the database server to switch to a different database. | |
std::string | server_version () |
Get the database server's version number. | |
std::string | set_option (Option *o) |
Sets a connection option. | |
bool | set_option (mysql_option moption, const void *arg=0) |
Set MySQL C API connection option. | |
bool | set_option (unsigned int option, bool arg) |
Set MySQL C API connection option. | |
std::string | set_option_default (Option *o) |
Same as set_option(), except that it won't override a previously-set option. | |
bool | shutdown () |
Ask database server to shut down. | |
std::string | server_status () |
Returns the database server's status. | |
MYSQL_RES * | store_result () |
Saves the results of the query just execute()d in memory and returns a pointer to the MySQL C API data structure the results are stored in. | |
unsigned long | thread_id () |
Returns the MySQL server thread ID for this connection. | |
MYSQL_RES * | use_result () |
Returns a result set from the last-executed query which we can walk through in linear fashion, which doesn't store all result sets in memory. | |
Static Public Member Functions | |
static size_t | escape_string_no_conn (char *to, const char *from, size_t length) |
SQL-escapes the given string without reference to the. | |
static bool | thread_aware () |
Returns true if MySQL++ and the underlying MySQL C API library were both compiled with thread awareness. | |
static void | thread_end () |
Tells the underlying MySQL C API library that this thread is done using the library. | |
static bool | thread_start () |
Tells the underlying C API library that the current thread will be using the library's services. |
This class does as little as possible to adapt between its public interface and the interface required by the underlying C API. That is, in fact, its only mission. The high-level interfaces indended for use by MySQL++ users are in Connection, Query, Result, and ResUse, all of which delegate the actual database communication to an object of this type, created by Connection. If you really need access to the low-level database driver, get it via Connection::driver(); don't create DBDriver objects directly.
Currently this is a concrete class for wrapping the MySQL C API. In the future, it may be turned into an abstract base class, with subclasses for different database server types.
|
Result code returned by next_result().
|
|
Duplicate an existing driver.
|
|
Return the number of rows affected by the last query.
Wraps |
|
Get database client library version.
Wraps |
|
Connect to database server. 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. |
|
Establish a new connection using the same parameters as an existing connection.
|
|
Return true if we have an active connection to the database server. This does not actually check whether the connection is viable, it just indicates whether there was previously a successful connect() call and no disconnect(). Call ping() to actually test the connection's viability. |
|
Establish a new connection as a copy of an existing one.
|
|
Ask the database server to create a database.
|
|
Seeks to a particualr row within the result set. Wraps mysql_data_seek() in MySQL C API. |
|
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.
Wraps |
|
Return error message for last MySQL error associated with this connection.
Can return a MySQL++ DBDriver-specific error message if there is one. If not, it simply wraps |
|
SQL-escapes the given string, taking into account the.
Wraps |
|
SQL-escapes the given string without reference to the.
Wraps |
|
Executes the given query string.
Wraps |
|
Returns information about a particular field in a result set.
Wraps |
|
Returns the lengths of the fields in the current row from a "use" query.
Wraps |
|
Returns the next raw C API row structure from the given result set. This is for "use" query result sets only. "store" queries have all the rows already.
Wraps |
|
Jumps to the given field within the result set.
Wraps |
|
Releases memory used by a result set.
Wraps |
|
Get ID generated for an AUTO_INCREMENT column in the previous INSERT query.
|
|
Get information about the IPC connection to the database server. String contains info about type of connection (e.g. TCP/IP, named pipe, Unix socket...) and the server hostname.
Wraps |
|
Kill a MySQL server thread.
|
|
Returns true if there are unconsumed results from the most recent query.
Wraps |
|
Moves to the next result set from a multi-query.
mysql_next_result() in the MySQL C API, with translation of its return value from magic integers to nr_code enum values. |
|
Returns the number of fields in the given result set.
Wraps |
|
Returns the number of rows in the given result set.
Wraps |
|
"Pings" the MySQL database
This function will try to reconnect to the server if the connection has been dropped. Wraps
|
|
Returns version number of MySQL protocol this connection is using.
Wraps |
|
Returns information about the last executed query.
Wraps |
|
Asks the database server to refresh certain internal data structures.
Wraps |
|
Returns true if the most recent result set was empty.
Wraps |
|
Returns the database server's status.
String is similar to that returned by the
Wraps |
|
Get the database server's version number.
Wraps |
|
Set MySQL C API connection option. Manipulates the MYSQL.client_flag bit mask. This allows these flags to be treated the same way as any other connection option, even though the C API handles them differently. |
|
Sets a connection option. This is the database-independent high-level option setting interface that Connection::set_option() calls. There are several private overloads that actually implement the option setting.
|
|
Ask database server to shut down. User must have the "shutdown" privilege.
Wraps |
|
Saves the results of the query just execute()d in memory and returns a pointer to the MySQL C API data structure the results are stored in.
mysql_store_result() in the MySQL C API. |
|
Returns true if MySQL++ and the underlying MySQL C API library were both compiled with thread awareness. This is based in part on a MySQL C API function mysql_thread_safe(). We deliberately don't call this wrapper thread_safe() because it's a misleading name: linking to thread-aware versions of the MySQL++ and C API libraries doesn't automatically make your program "thread-safe". See the chapter on threads in the user manual for more information and guidance. |
|
Tells the underlying MySQL C API library that this thread is done using the library. This exists because the MySQL C API library allocates some per-thread memory which it doesn't release until you call this. |
|
Returns the MySQL server thread ID for this connection. This has nothing to do with threading on the client side. It's a server-side thread ID, to be used with kill(). |
|
Tells the underlying C API library that the current thread will be using the library's services.
|
|
Returns a result set from the last-executed query which we can walk through in linear fashion, which doesn't store all result sets in memory.
mysql_use_result() in the MySQL C API. |