#include <mcs.hh>
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. | |
DBConn * | newDBConn () |
Creates a new DB connection with the same parameters. | |
DBConn & | operator= (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 |
mcs::DBConn::DBConn | ( | const DBConn & | ) |
Declared to avoid using of default copy constructor.
void mcs::DBConn::connect | ( | string | user, | |
string | pass, | |||
string | db, | |||
string | host = "" | |||
) |
Connect to a databae server.
user | User name. | |
pass | User password. | |
db | Database name to connect to. | |
host | Host running database server, if empty localhost will be used. |
ERROR | MSG_CANT_ALLOCATE_MYSQL; | |
ERROR | MSG_CANT_OPEN_MYSQL_CONNECTION. |
unsigned long mcs::DBConn::id | ( | ) |
bool mcs::DBConn::isOpen | ( | ) |
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.
ERROR | MSG_CANT_OPEN_MYSQL_CONNECTION. |
Declared to avoid using of default assignment operator.
MYSQL* mcs::DBConn::lconn [private] |
bool mcs::DBConn::lconnInitialized [private] |
bool mcs::DBConn::lconnOpened [private] |
string mcs::DBConn::ldb [private] |
string mcs::DBConn::lhost [private] |
string mcs::DBConn::lpass [private] |
string mcs::DBConn::luser [private] |
![]() |
MCS (My Customizable Server) ver. 0.3.3-alpha3
|