mcs::DBConn Class Reference

#include <mcs.hh>

List of all members.


Detailed Description

Handle database connection.

You can use this class to connect to a database. To perform queries on the database you should use a Query object, whose methods require a DBConn object as parameter.

Definition at line 5447 of file mcs.hh.


Public Member Functions

void close ()
 Closes a db connection.
void connect (string user, string pass, string db, string host="")
 Connect to a databae server.
 DBConn ()
 Constructor.
 DBConn (const DBConn &)
 Declared to avoid using of default copy constructor.
unsigned long id ()
 Returns the same value as mysql_thread_id.
bool isOpen ()
 Tell if a connection to the server is opened.
DBConnnewDBConn ()
 Creates a new DB connection with the same parameters.
DBConnoperator= (const DBConn &)
 Declared to avoid using of default assignment operator.
 ~DBConn ()
 Destructor, calls close().

Private Attributes

MYSQL * lconn
 MYSQL connection structure.
bool lconnInitialized
 True if the connection has been initialized.
bool lconnOpened
 True if the connection has been opened.
string ldb
 Database name to connect to.
string lhost
 Host running database server.
string lpass
 User password.
string luser
 User name.
 MCS_DEBUG_ALLOC

Friends

class Query

Constructor & Destructor Documentation

mcs::DBConn::DBConn ( const DBConn  ) 

Declared to avoid using of default copy constructor.

Warning:
This constructor is declared but not implemented. If you try to use it you will get a compilation error.

mcs::DBConn::DBConn (  ) 

Constructor.

Definition at line 30 of file Db.cc.

mcs::DBConn::~DBConn (  ) 

Destructor, calls close().

Definition at line 39 of file Db.cc.


Member Function Documentation

void mcs::DBConn::close (  ) 

Closes a db connection.

Definition at line 71 of file Db.cc.

void mcs::DBConn::connect ( string  user,
string  pass,
string  db,
string  host = "" 
)

Connect to a databae server.

Parameters:
user User name.
pass User password.
db Database name to connect to.
host Host running database server, if empty localhost will be used.
Exceptions:
ERROR MSG_CANT_ALLOCATE_MYSQL;
ERROR MSG_CANT_OPEN_MYSQL_CONNECTION.
See also:
DBConn_connect().

Definition at line 44 of file Db.cc.

unsigned long mcs::DBConn::id (  ) 

Returns the same value as mysql_thread_id.

Definition at line 97 of file Db.cc.

bool mcs::DBConn::isOpen (  ) 

Tell if a connection to the server is opened.

Definition at line 91 of file Db.cc.

DBConn * mcs::DBConn::newDBConn (  ) 

Creates a new DB connection with the same parameters.

A DBConn object can maintain only one prepared statement at a time. So if you want to use several prepared statement you must use different DBConn objects. With this method you istantiate on the heap a new DBConn object and call its connect method() with the same parameters used to connect with the actual object. It's user responsibility to delete objects created with this method.

Returns:
Address of the newly created DBConn object.
Exceptions:
ERROR MSG_CANT_OPEN_MYSQL_CONNECTION.

Definition at line 103 of file Db.cc.

DBConn& mcs::DBConn::operator= ( const DBConn  ) 

Declared to avoid using of default assignment operator.

Warning:
This operator is declared but not implemented. If you try to use it you will get a compilation error.


Member Data Documentation

MYSQL* mcs::DBConn::lconn [private]

MYSQL connection structure.

Definition at line 5453 of file mcs.hh.

bool mcs::DBConn::lconnInitialized [private]

True if the connection has been initialized.

Definition at line 5456 of file mcs.hh.

bool mcs::DBConn::lconnOpened [private]

True if the connection has been opened.

Definition at line 5459 of file mcs.hh.

string mcs::DBConn::ldb [private]

Database name to connect to.

Definition at line 5468 of file mcs.hh.

string mcs::DBConn::lhost [private]

Host running database server.

Definition at line 5471 of file mcs.hh.

string mcs::DBConn::lpass [private]

User password.

Definition at line 5465 of file mcs.hh.

string mcs::DBConn::luser [private]

User name.

Definition at line 5462 of file mcs.hh.


The documentation for this class was generated from the following files:
mcslogo

MCS (My Customizable Server) ver. 0.3.3-alpha3
Documentation generated on Thu Mar 22 13:22:23 UTC 2012