MCS
0.3.3-alpha7
|
Handle database connection. More...
#include <mcs.hh>
Public Member Functions | |
void | close () |
Closes a db connection. More... | |
void | connect (string user, string pass, string db, string host="") |
Connect to a databae server. More... | |
DBConn (const DBConn &) | |
Declared to avoid using of default copy constructor. More... | |
DBConn () | |
Constructor. More... | |
unsigned long | id () |
Returns the same value as mysql_thread_id. More... | |
bool | isOpen () |
Tell if a connection to the server is opened. More... | |
DBConn * | newDBConn () |
Creates a new DB connection with the same parameters. More... | |
DBConn & | operator= (const DBConn &) |
Declared to avoid using of default assignment operator. More... | |
~DBConn () | |
Destructor, calls close(). More... | |
Private Attributes | |
MYSQL * | lconn |
MYSQL connection structure. More... | |
bool | lconnInitialized |
True if the connection has been initialized. More... | |
bool | lconnOpened |
True if the connection has been opened. More... | |
string | ldb |
Database name to connect to. More... | |
string | lhost |
Host running database server. More... | |
string | lpass |
User password. More... | |
string | luser |
User name. More... | |
MCS_DEBUG_ALLOC | |
Friends | |
class | Query |
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.
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.
|
private |
|
private |
|
private |
|
private |
|
private |
![]() |
MCS (My Customizable Server) ver. 0.3.3-alpha7
|