Home » U++ Library support » U++ SQL » MySql.cpp (MySqlSession::Connect)
MySql.cpp (MySqlSession::Connect) [message #4376] |
Thu, 03 August 2006 17:49 |
Ptomaine
Messages: 11 Registered: July 2006
|
Promising Member |
|
|
Hi there!
It would be much more better to know an error if a connection failed. Here is the draft code to implement the task.
bool MySqlSession::Connect(const char *user, const char *password, const char *database,
const char *host, int port, const char *socket) {
mysql = mysql_init((MYSQL*) 0);
if(mysql && mysql_real_connect(mysql, sEmpNull(host), sEmpNull(user),
sEmpNull(password), sEmpNull(database), port,
sEmpNull(socket), 0)) {
Sql sql(*this);
username = sql.Select("substring_index(USER(),'@',1)");
return true;
}
errorstatement = mysql->net.last_error-2; //we must substract 2 to fix MySQL Server 5.0.19 bug.
Close();
return false;
}
[Updated on: Thu, 03 August 2006 17:53] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
Goto Forum:
Current Time: Sun Apr 28 22:51:14 CEST 2024
Total time taken to generate the page: 0.05030 seconds
|