simple MySQL login to database More...

Public Member Functions | |
| this (MSqlEnv env, in char[] username, in char[] password, in char[] db_name, in char[] host="localhost", uint port=3306, uint clientflag=0) | |
| void | connect (in char[] username, in char[] password, in char[] db_name, in char[] host="localhost", uint port=3306, uint clientflag=0) |
| ~this () | |
| version (MYSQLPL_PREP_STMT) | |
Public Attributes | |
| MYSQL * | _db |
| bool | _connected |
simple MySQL login to database
Definition at line 445 of file mysqlpl.d.
| mysqlpl::MSqlConnection::this | ( | MSqlEnv | env, |
| in char[] | username, | ||
| in char[] | password, | ||
| in char[] | db_name, | ||
| in char[] | host = "localhost", |
||
| uint | port = 3306, |
||
| uint | clientflag = 0 |
||
| ) | [inline] |
Definition at line 447 of file mysqlpl.d.
{
_env = env;
_db = null;
_connected = false;
connect(username, password, db_name, host, port, clientflag);
}
| mysqlpl::MSqlConnection::~this | ( | ) | [inline] |
| void mysqlpl::MSqlConnection::connect | ( | in char[] | username, |
| in char[] | password, | ||
| in char[] | db_name, | ||
| in char[] | host = "localhost", |
||
| uint | port = 3306, |
||
| uint | clientflag = 0 |
||
| ) | [inline] |
Definition at line 457 of file mysqlpl.d.
References mysqlpl::mysqlpl_check_error(), and mysqlpl::version().
{
_connected = false;
_db = mysqlpl_real_connect(_env(), toStringz(host), toStringz(username), toStringz(password), toStringz(db_name), port, null, clientflag);
if (!_db)
throw new MSqlException(_env());
_connected = true;
version(MYSQLPL_PREP_STMT) {
// disable auto commit mode
my_bool res = mysqlpl_autocommit(_db, 0);
mysqlpl_check_error(_env(), res);
} else {
(new SqlStatement(this)).execute("set autocommit=0"); // "set autocommit=0" is not supported before MySQL 4.1
}
}

| mysqlpl::MSqlConnection::version | ( | MYSQLPL_PREP_STMT | ) | [inline] |
Definition at line 487 of file mysqlpl.d.
{
// get warnings
uint get_warnings_count()
{
uint res = mysqlpl_warning_count(_db);
if (res == -1)
throw new MSqlException(_db);
return res;
}
char[] get_info()
{
char* info = mysqlpl_info(_db);
if (!info)
throw new MSqlException(_db);
return info[0 .. info?strlen(info):0];
}
void print_warnings(Stream o)
{
while(get_warnings_count())
o.writeString(get_info() ~ '\n');
}
} else { // version(MYSQLPL_PREP_STMT)
| MYSQL* mysqlpl::MSqlConnection::_db |
1.7.2