28 #if !defined(MYSQLPP_DBDRIVER_H) 
   29 #define MYSQLPP_DBDRIVER_H 
   87                 error_message_.clear();
 
   88                 return mysql_affected_rows(&mysql_);
 
   96                 error_message_.clear();
 
   97                 return mysql_get_client_info();
 
  104         bool connect(
const MYSQL& mysql);
 
  111         virtual bool connect(
const char* host, 
const char* socket_name,
 
  112                         unsigned int port, 
const char* db, 
const char* user,
 
  113                         const char* password);
 
  134         bool create_db(
const char* db) 
const;
 
  141                 error_message_.clear();
 
  142                 mysql_data_seek(res, offset);
 
  157         bool drop_db(
const std::string& db) 
const;
 
  174         bool enable_ssl(
const char* key = 0, 
const char* cert = 0,
 
  175                         const char* ca = 0, 
const char* capath = 0,
 
  176                         const char* cipher = 0);
 
  185                 return error_message_.length() ? error_message_.c_str() : mysql_error(&mysql_);
 
  192         int errnum() { 
return mysql_errno(&mysql_); }
 
  213                 error_message_.clear();
 
  214                 return mysql_real_escape_string(&mysql_, to, from, 
 
  215                                 static_cast<unsigned long>(length));
 
  257         size_t escape_string(std::string* ps, 
const char* original,
 
  269                 return mysql_escape_string(to, from,
 
  270                                 static_cast<unsigned long>(length));
 
  278         static size_t escape_string_no_conn(std::string* ps, 
 
  279                         const char* original = 0, 
size_t length = 0);
 
  286                 error_message_.clear();
 
  287                 return !mysql_real_query(&mysql_, qstr,
 
  288                                 static_cast<unsigned long>(length));
 
  300                 error_message_.clear();
 
  301                 return mysql_fetch_row(res);
 
  310                 error_message_.clear();
 
  311                 return mysql_fetch_lengths(res);
 
  327         MYSQL_FIELD* 
fetch_field(MYSQL_RES* res, 
size_t i = UINT_MAX)
 const 
  329                 error_message_.clear();
 
  330                 return i == UINT_MAX ? mysql_fetch_field(res) :
 
  331                                 mysql_fetch_field_direct(res,
 
  332                                 static_cast<unsigned int>(i));
 
  340                 error_message_.clear();
 
  341                 mysql_field_seek(res, MYSQL_FIELD_OFFSET(field));
 
  349                 error_message_.clear();
 
  350                 mysql_free_result(res);
 
  365                 error_message_.clear();
 
  366                 return mysql_get_host_info(&mysql_);
 
  381                 error_message_.clear();
 
  382                 return mysql_insert_id(&mysql_);
 
  394                 error_message_.clear();
 
  395                 return !mysql_kill(&mysql_, tid);
 
  404                 error_message_.clear();
 
  405                 #if MYSQL_VERSION_ID > 41000            // only in MySQL v4.1 + 
  406                         return mysql_more_results(&mysql_);
 
  423                 error_message_.clear();
 
  424                 #if MYSQL_VERSION_ID > 41000            // only in MySQL v4.1 + 
  425                         switch (mysql_next_result(&mysql_)) {
 
  426                                 case 0:  
return nr_more_results;
 
  427                                 case -1: 
return nr_last_result;
 
  428                                 default: 
return nr_error;
 
  431                         return nr_not_supported;
 
  440                 error_message_.clear();
 
  441                 return mysql_num_fields(res);
 
  449                 error_message_.clear();
 
  450                 return mysql_num_rows(res);
 
  465                 error_message_.clear();
 
  466                 return !mysql_ping(&mysql_);
 
  475                 error_message_.clear();
 
  476                 return mysql_get_proto_info(&mysql_);
 
  482         std::string query_info();
 
  494                 error_message_.clear();
 
  495                 return !mysql_refresh(&mysql_, options);
 
  504                 error_message_.clear();
 
  505                 return mysql_field_count(&mysql_) == 0;
 
  511                 error_message_.clear();
 
  512                 return !mysql_select_db(&mysql_, db);
 
  520                 error_message_.clear();
 
  521                 return mysql_get_server_info(&mysql_);
 
  532         bool set_option(
Option* o);
 
  539                 error_message_.clear();
 
  540                 return !mysql_options(&mysql_, moption,
 
  541                                 static_cast<const char*>(arg));
 
  544         #if MYSQL_VERSION_ID >= 40101 
  545         bool set_option(enum_mysql_set_option msoption)
 
  550                 error_message_.clear();
 
  551                 return !mysql_set_server_option(&mysql_, msoption);
 
  560         bool set_option(
unsigned int option, 
bool arg);
 
  566                 const std::type_info& ti = 
typeid(o);
 
  567                 for (OptionList::const_iterator it = applied_options_.begin();
 
  568                                 it != applied_options_.end();
 
  570                         if (
typeid(*it) == ti) {
 
  576                 return set_option(o);
 
  596                 error_message_.clear();
 
  597                 return mysql_stat(&mysql_);
 
  609                 error_message_.clear();
 
  610                 return mysql_store_result(&mysql_);
 
  623         static bool thread_aware();
 
  632                 #if MYSQL_VERSION_ID > 40000            // only in MySQL v4.0 + 
  643                 error_message_.clear();
 
  644                 return mysql_thread_id(&mysql_);
 
  667                 #if MYSQL_VERSION_ID > 40000            // only in MySQL v4.0 + 
  668                         return !mysql_thread_init();
 
  683                 error_message_.clear();
 
  684                 return mysql_use_result(&mysql_);
 
  690         bool connect_prepare();
 
  694         bool set_option_impl(
Option* o);
 
  698         typedef std::deque<Option*> OptionList;
 
  701         typedef OptionList::iterator OptionListIt;
 
  709         OptionList applied_options_;
 
  710         OptionList pending_options_;
 
  711         mutable std::string error_message_;
 
  717 #endif // !defined(MYSQLPP_DBDRIVER_H) 
st_mysql_options get_options() const 
Return the connection options object. 
Definition: dbdriver.h:354
ulonglong insert_id()
Get ID generated for an AUTO_INCREMENT column in the previous INSERT query. 
Definition: dbdriver.h:379
bool ping()
"Pings" the MySQL database 
Definition: dbdriver.h:463
bool connected() const 
Return true if we have an active connection to the database server. 
Definition: dbdriver.h:122
bool set_option(mysql_option moption, const void *arg=0)
Set MySQL C API connection option. 
Definition: dbdriver.h:537
static bool thread_start()
Tells the underlying C API library that the current thread will be using the library's services...
Definition: dbdriver.h:665
success, with more results to come 
Definition: dbdriver.h:62
void data_seek(MYSQL_RES *res, ulonglong offset) const 
Seeks to a particualr row within the result set. 
Definition: dbdriver.h:139
static void thread_end()
Tells the underlying MySQL C API library that this thread is done using the library. 
Definition: dbdriver.h:630
ulonglong affected_rows()
Return the number of rows affected by the last query. 
Definition: dbdriver.h:85
bool set_option_default(Option *o)
Same as set_option(), except that it won't override a previously-set option. 
Definition: dbdriver.h:564
ulonglong num_rows(MYSQL_RES *res) const 
Returns the number of rows in the given result set. 
Definition: dbdriver.h:447
int protocol_version()
Returns version number of MySQL protocol this connection is using. 
Definition: dbdriver.h:473
static size_t escape_string_no_conn(char *to, const char *from, size_t length)
SQL-escapes the given string without reference to the character set of a database server...
Definition: dbdriver.h:266
const char * error()
Return error message for last MySQL error associated with this connection. 
Definition: dbdriver.h:183
nr_code
Result code returned by next_result() 
Definition: dbdriver.h:61
nr_code next_result()
Moves to the next result set from a multi-query. 
Definition: dbdriver.h:421
void field_seek(MYSQL_RES *res, size_t field) const 
Jumps to the given field within the result set. 
Definition: dbdriver.h:338
Define abstract interface for all *Option subclasses. 
Definition: options.h:57
void free_result(MYSQL_RES *res) const 
Releases memory used by a result set. 
Definition: dbdriver.h:347
const unsigned long * fetch_lengths(MYSQL_RES *res) const 
Returns the lengths of the fields in the current row from a "use" query. 
Definition: dbdriver.h:308
std::string server_status()
Returns the database server's status. 
Definition: dbdriver.h:594
std::string server_version()
Get the database server's version number. 
Definition: dbdriver.h:518
std::string client_version() const 
Get database client library version. 
Definition: dbdriver.h:94
MYSQL_RES * store_result()
Saves the results of the query just execute()d in memory and returns a pointer to the MySQL C API dat...
Definition: dbdriver.h:607
bool result_empty()
Returns true if the most recent result set was empty. 
Definition: dbdriver.h:502
bool more_results()
Returns true if there are unconsumed results from the most recent query. 
Definition: dbdriver.h:402
problem retrieving next result 
Definition: dbdriver.h:64
MYSQL_ROW fetch_row(MYSQL_RES *res) const 
Returns the next raw C API row structure from the given result set. 
Definition: dbdriver.h:298
success, last result received 
Definition: dbdriver.h:63
bool kill(unsigned long tid)
Kill a MySQL server thread. 
Definition: dbdriver.h:392
bool select_db(const char *db)
Asks the database server to switch to a different database. 
Definition: dbdriver.h:509
std::string ipc_info()
Get information about the IPC connection to the database server. 
Definition: dbdriver.h:363
unsigned long thread_id()
Returns the MySQL server thread ID for this connection. 
Definition: dbdriver.h:641
bool refresh(unsigned options)
Asks the database server to refresh certain internal data structures. 
Definition: dbdriver.h:492
This file includes top-level definitions for use both internal to the library, and outside it...
int num_fields(MYSQL_RES *res) const 
Returns the number of fields in the given result set. 
Definition: dbdriver.h:438
int errnum()
Return last MySQL error number associated with this connection. 
Definition: dbdriver.h:192
Declares the Option class hierarchy, used to implement connection options in Connection and DBDriver ...
MYSQL_RES * use_result()
Returns a result set from the last-executed query which we can walk through in linear fashion...
Definition: dbdriver.h:681
MYSQL_FIELD * fetch_field(MYSQL_RES *res, size_t i=UINT_MAX) const 
Returns information about a particular field in a result set. 
Definition: dbdriver.h:327
bool execute(const char *qstr, size_t length)
Executes the given query string. 
Definition: dbdriver.h:284
size_t escape_string(char *to, const char *from, size_t length)
Return a SQL-escaped version of the given character buffer. 
Definition: dbdriver.h:211
Provides a thin abstraction layer over the underlying database client library. 
Definition: dbdriver.h:57