|
|
|
@ -166,11 +166,14 @@ AAssoc *MySQL_Connector::Query( CSTR QS, bool useCache ){ |
|
|
|
Assoc * tElement; |
|
|
|
unsigned int num_Fields; |
|
|
|
MYSQL_RES * Result = NULL; |
|
|
|
char temp[256]; |
|
|
|
|
|
|
|
m_mAccessMutex.lock(); |
|
|
|
#ifdef DEBUG_MYSQL_QUERIES
|
|
|
|
LOG( QS ); |
|
|
|
#endif
|
|
|
|
if ( mysql_query( m_pDBLink, QS ) ) { |
|
|
|
/*
|
|
|
|
if( mysql_query( m_pDBLink, QS ) ){ |
|
|
|
LOG_ERROR( mysql_error( m_pDBLink )); |
|
|
|
|
|
|
|
char temp[256]; |
|
|
|
@ -179,13 +182,14 @@ AAssoc *MySQL_Connector::Query( CSTR QS, bool useCache ){ |
|
|
|
|
|
|
|
switch( mysql_errno( m_pDBLink ) ){ |
|
|
|
case 1156: |
|
|
|
case 2006:{// Server Gone
|
|
|
|
case 2006: |
|
|
|
case 2013:{// Server Gone
|
|
|
|
if( ReConnect() ){ |
|
|
|
if ( !mysql_query( m_pDBLink, QS ) ){ |
|
|
|
Result = mysql_store_result( m_pDBLink ); |
|
|
|
} else { |
|
|
|
LOG_ERROR( mysql_error( m_pDBLink )); |
|
|
|
sprintf( temp, "Error Code: %d", mysql_errno( m_pDBLink )); |
|
|
|
sprintf( temp, "Reconnect Error Code: %d", mysql_errno( m_pDBLink )); |
|
|
|
LOG_ERROR( temp ); |
|
|
|
}; |
|
|
|
}; |
|
|
|
@ -194,7 +198,22 @@ AAssoc *MySQL_Connector::Query( CSTR QS, bool useCache ){ |
|
|
|
}; |
|
|
|
} else { |
|
|
|
Result = mysql_store_result( m_pDBLink ); |
|
|
|
};*/ |
|
|
|
while ( mysql_query( m_pDBLink, QS ) ) { |
|
|
|
LOG_ERROR( mysql_error( m_pDBLink )); |
|
|
|
sprintf( temp, "Error Code: %d", mysql_errno( m_pDBLink )); |
|
|
|
LOG_ERROR( temp ); |
|
|
|
switch( mysql_errno( m_pDBLink ) ) { |
|
|
|
case 1156: |
|
|
|
case 2006: |
|
|
|
case 2013:{ |
|
|
|
ReConnect(); |
|
|
|
continue; |
|
|
|
}; |
|
|
|
}; |
|
|
|
break; |
|
|
|
}; |
|
|
|
Result = mysql_store_result( m_pDBLink ); |
|
|
|
if( Result!= NULL ){ |
|
|
|
if ( mysql_num_rows( Result ) ) { |
|
|
|
RetVal = new AAssoc(); |
|
|
|
@ -260,40 +279,51 @@ CSTR MySQL_Connector::escapeString( CSTR str ){ |
|
|
|
|
|
|
|
uint64_t MySQL_Connector::QueryID( CSTR QS ){ |
|
|
|
uint64_t RetVal = 0; |
|
|
|
char temp[256]; |
|
|
|
|
|
|
|
m_mAccessMutex.lock(); |
|
|
|
#ifdef DEBUG_MYSQL_QUERIES
|
|
|
|
LOG( QS ); |
|
|
|
#endif
|
|
|
|
while ( mysql_query( m_pDBLink, QS ) ) { |
|
|
|
LOG_ERROR( mysql_error( m_pDBLink )); |
|
|
|
char temp[256]; |
|
|
|
LOG_ERROR( mysql_error( m_pDBLink )); |
|
|
|
sprintf( temp, "Error Code: %d", mysql_errno( m_pDBLink )); |
|
|
|
LOG_ERROR( temp ); |
|
|
|
if( mysql_errno( m_pDBLink ) == 2013 || mysql_errno( m_pDBLink ) == 2006 ) { |
|
|
|
ReConnect(); |
|
|
|
} else break; |
|
|
|
switch( mysql_errno( m_pDBLink ) ) { |
|
|
|
case 1156: |
|
|
|
case 2006: |
|
|
|
case 2013:{ |
|
|
|
ReConnect(); |
|
|
|
continue; |
|
|
|
}; |
|
|
|
}; |
|
|
|
break; |
|
|
|
}; |
|
|
|
//LOG("Query Issued");
|
|
|
|
RetVal = ( uint64_t ) mysql_insert_id( m_pDBLink ); |
|
|
|
//LOG("ID Receved");
|
|
|
|
m_mAccessMutex.unlock(); |
|
|
|
//LOG("Mutex Unlocked");
|
|
|
|
return RetVal; |
|
|
|
}; |
|
|
|
|
|
|
|
void MySQL_Connector::SilentQuery( CSTR QS ){ |
|
|
|
char temp[256]; |
|
|
|
|
|
|
|
m_mAccessMutex.lock(); |
|
|
|
#ifdef DEBUG_MYSQL_QUERIES
|
|
|
|
LOG( QS ); |
|
|
|
#endif
|
|
|
|
while ( mysql_query( m_pDBLink, QS ) ) { |
|
|
|
LOG_ERROR( mysql_error( m_pDBLink )); |
|
|
|
char temp[256]; |
|
|
|
LOG_ERROR( mysql_error( m_pDBLink )); |
|
|
|
sprintf( temp, "Error Code: %d", mysql_errno( m_pDBLink )); |
|
|
|
LOG_ERROR( temp ); |
|
|
|
if( mysql_errno( m_pDBLink ) == 2013 || mysql_errno( m_pDBLink ) == 2006 ) { |
|
|
|
ReConnect(); |
|
|
|
} else break; |
|
|
|
switch( mysql_errno( m_pDBLink ) ) { |
|
|
|
case 1156: |
|
|
|
case 2006: |
|
|
|
case 2013:{ |
|
|
|
ReConnect(); |
|
|
|
continue; |
|
|
|
}; |
|
|
|
}; |
|
|
|
break; |
|
|
|
}; |
|
|
|
m_mAccessMutex.unlock(); |
|
|
|
}; |
|
|
|
|