Home » U++ Library support » U++ SQL » Added code to MySqlSession::DoConnect() correct?
Added code to MySqlSession::DoConnect() correct? [message #40279] |
Mon, 15 July 2013 00:29 |
|
Alboni
Messages: 214 Registered: January 2012 Location: Deventer, Netherlands
|
Experienced Member |
|
|
Gentlemen,
I added some code to MySqlSession::DoConnect() so I could retrieve the proper errormessage if Connect would fail.
My question: Am I using the proper variables for this or could this disrupt something ?
bool MySqlSession::DoConnect()
{
mysql = mysql_init((MYSQL*) 0);
level = 0;
if(mysql)
{
if (mysql_real_connect(mysql, sEmpNull(connect_host), sEmpNull(connect_user),
sEmpNull(connect_password), sEmpNull(connect_database),
connect_port, sEmpNull(connect_socket), 0))
{
Sql sql(*this);
username = sql.Select("substring_index(USER(),'@',1)");
mysql_set_character_set(mysql, "utf8");
sql.Execute("SET NAMES 'utf8'");
sql.Execute("SET CHARACTER SET utf8");
return true;
}
/*added*/ errorcode_number=mysql_errno(mysql);
/*added*/ errorcode_string=mysql_error(mysql);
/*added*/ lasterror=errorcode_string; // what's the difference?
}
Close();
return false;
}
|
|
|
|
Goto Forum:
Current Time: Wed Jun 05 07:01:08 CEST 2024
Total time taken to generate the page: 0.01604 seconds
|