Commit c4b0dfe5 authored by Aleksey Vinogradov's avatar Aleksey Vinogradov Committed by Pavel Vainerman

исправлены ошибки

parent 00d91c6d
...@@ -30,7 +30,8 @@ using namespace std; ...@@ -30,7 +30,8 @@ using namespace std;
DBInterface::DBInterface(): DBInterface::DBInterface():
result(0), result(0),
lastQ(""), lastQ(""),
queryok(false) queryok(false),
connected(false)
{ {
mysql = new MYSQL(); mysql = new MYSQL();
} }
...@@ -52,9 +53,11 @@ bool DBInterface::connect( const string host, const string user, const string ps ...@@ -52,9 +53,11 @@ bool DBInterface::connect( const string host, const string user, const string ps
{ {
cout << error() << endl; cout << error() << endl;
mysql_close(mysql); mysql_close(mysql);
connected = false;
return false; return false;
} }
connected = true;
return true; return true;
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
...@@ -108,7 +111,7 @@ bool DBInterface::nextRecord() ...@@ -108,7 +111,7 @@ bool DBInterface::nextRecord()
if( !mysql || !result || !queryok ) if( !mysql || !result || !queryok )
return false; return false;
if( Row == mysql_fetch_row(result) ) if( Row = mysql_fetch_row(result) )
return true; return true;
return false; return false;
...@@ -219,7 +222,8 @@ bool DBInterface::ping() ...@@ -219,7 +222,8 @@ bool DBInterface::ping()
{ {
if(!mysql) if(!mysql)
return false; return false;
if(!connected)
return false;
// внимание mysql_ping возвращает 0 // внимание mysql_ping возвращает 0
// если всё хорошо.... (поэтому мы инвертируем) // если всё хорошо.... (поэтому мы инвертируем)
return !mysql_ping(mysql); return !mysql_ping(mysql);
......
...@@ -87,6 +87,7 @@ class DBInterface ...@@ -87,6 +87,7 @@ class DBInterface
MYSQL *mysql; MYSQL *mysql;
string lastQ; string lastQ;
bool queryok; // успешность текущего запроса bool queryok; // успешность текущего запроса
bool connected;
}; };
// ---------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment