simple MySQL login to database More...
#include <mysqlpl.h>

Public Member Functions | |
| MSqlConnection (MSqlEnv &env) | |
| MSqlConnection (MSqlEnv &env, const char *username, const char *password, const char *db_name, const char *host="localhost", unsigned port=3306, unsigned long clientflag=0) | |
| void | connect (const char *username, const char *password, const char *db_name, const char *host="localhost", unsigned port=3306, unsigned long clientflag=0) | 
| ~MSqlConnection () | |
| const char * | get_info () const | 
| void | print_warnings (std::ostream &out) | 
| LONGLONG | get_insert_id () const | 
| void | commit () | 
| void | rollback () | 
| operator MYSQL * () const | |
Protected Attributes | |
| MSqlEnv & | _env | 
| MYSQL * | _db | 
| bool | _connected | 
Private Member Functions | |
| MSqlConnection (const MSqlConnection &) | |
simple MySQL login to database
Definition at line 218 of file mysqlpl.h.
| MySqlPL::MSqlConnection::MSqlConnection | ( | MSqlEnv & | env ) |  [inline] | 
        
Definition at line 220 of file mysqlpl.h.
: _env(env), _db(NULL), _connected(false) { }
| MySqlPL::MSqlConnection::MSqlConnection | ( | MSqlEnv & | env, | 
| const char * | username, | ||
| const char * | password, | ||
| const char * | db_name, | ||
| const char * |  host = "localhost",  | 
        ||
| unsigned |  port = 3306,  | 
        ||
| unsigned long |  clientflag = 0  | 
        ||
| ) |  [inline] | 
        
| MySqlPL::MSqlConnection::~MSqlConnection | ( | ) |  [inline] | 
        
| MySqlPL::MSqlConnection::MSqlConnection | ( | const MSqlConnection & | ) |  [private] | 
        
| void MySqlPL::MSqlConnection::commit | ( | ) |  [inline] | 
        
Definition at line 278 of file mysqlpl.h.
References _db, _env, and MySqlPL::mysqlpl_check_error().
    {
#if MYSQLPL_PREP_STMT
        my_bool res = mysql_commit(_db);
#else
        my_bool res = mysql_query(_db, "commit");
#endif
        mysqlpl_check_error(_env, res);
    }

| void MySqlPL::MSqlConnection::connect | ( | const char * | username, | 
| const char * | password, | ||
| const char * | db_name, | ||
| const char * |  host = "localhost",  | 
        ||
| unsigned |  port = 3306,  | 
        ||
| unsigned long |  clientflag = 0  | 
        ||
| ) | 
Definition at line 154 of file mysqlpl.cpp.
References _connected, _db, _env, MySqlPL::SqlStatement::execute(), MySqlPL::mysqlpl_check_error(), and THROW_MYSQLPL_EXCEPTION.
Referenced by MSqlConnection().
{
    _connected = false;
    _db = mysql_real_connect(_env, host, username, password, db_name, port, NULL, clientflag);
    if (!_db)
        THROW_MYSQLPL_EXCEPTION(_env);
    _connected = true;
#if MYSQLPL_PREP_STMT
     // disable auto commit mode
    my_bool res = mysql_autocommit(_db, 0);
    mysqlpl_check_error(_env, res);
#else
    SqlStatement(*this).execute("set autocommit=0");    // "set autocommit=0" is not supported before MySQL 4.1
#endif
}


| const char * MySqlPL::MSqlConnection::get_info | ( | ) | const | 
Definition at line 197 of file mysqlpl.cpp.
References _db.
Referenced by print_warnings().
{
    return mysql_info(_db);
}

| LONGLONG MySqlPL::MSqlConnection::get_insert_id | ( | ) |  const [inline] | 
        
| MySqlPL::MSqlConnection::operator MYSQL * | ( | ) |  const [inline] | 
        
| void MySqlPL::MSqlConnection::print_warnings | ( | std::ostream & | out ) |  [inline] | 
        
Definition at line 262 of file mysqlpl.h.
References get_info().
    {
        const char* info = get_info();
        if (info)
            out << info << std::endl;
    }

| void MySqlPL::MSqlConnection::rollback | ( | ) |  [inline] | 
        
Definition at line 288 of file mysqlpl.h.
References _db, _env, and MySqlPL::mysqlpl_check_error().
    {
#if MYSQLPL_PREP_STMT   //@@
        my_bool res = mysql_rollback(_db);
#else
        my_bool res = mysql_query(_db, "rollback");
#endif
        mysqlpl_check_error(_env, res);
    }

bool MySqlPL::MSqlConnection::_connected [protected] | 
        
MYSQL* MySqlPL::MSqlConnection::_db [protected] | 
        
Definition at line 302 of file mysqlpl.h.
Referenced by commit(), connect(), get_info(), get_insert_id(), operator MYSQL *(), and rollback().
MSqlEnv& MySqlPL::MSqlConnection::_env [protected] | 
        
Definition at line 301 of file mysqlpl.h.
Referenced by commit(), connect(), and rollback().
 1.7.2