use new db functions in zm_config.cpp
parent
5a363273a2
commit
60410c98d6
|
@ -115,30 +115,13 @@ void zmLoadConfig()
|
|||
if ( ! staticConfig.SERVER_ID ) {
|
||||
if ( ! staticConfig.SERVER_NAME.empty() ) {
|
||||
|
||||
|
||||
std::string sql = stringtf("SELECT Id FROM Servers WHERE Name='%s'", staticConfig.SERVER_NAME.c_str() );
|
||||
if ( mysql_query( &dbconn, sql.c_str() ) )
|
||||
{
|
||||
Error( "Can't run query: %s", mysql_error( &dbconn ) );
|
||||
Fatal("Can't get ServerId for Server %s", staticConfig.SERVER_NAME.c_str() );
|
||||
}
|
||||
MYSQL_RES *result = mysql_store_result( &dbconn );
|
||||
if ( !result )
|
||||
{
|
||||
Error( "Can't use query result: %s", mysql_error( &dbconn ) );
|
||||
Fatal("Can't get ServerId for Server %s", staticConfig.SERVER_NAME.c_str() );
|
||||
}
|
||||
int n_rows = mysql_num_rows( result );
|
||||
if ( n_rows != 1 )
|
||||
{
|
||||
Error( "Bogus number of lines return from Server lookup, %d, returned. Can't reload", n_rows );
|
||||
Fatal("Can't get ServerId for Server %s", staticConfig.SERVER_NAME.c_str() );
|
||||
}
|
||||
|
||||
if ( MYSQL_ROW dbrow = mysql_fetch_row( result ) )
|
||||
{
|
||||
if ( MYSQL_ROW dbrow = zmDbFetchOne( sql.c_str() ) ) {
|
||||
staticConfig.SERVER_ID = atoi(dbrow[0]);
|
||||
} else {
|
||||
Fatal("Can't get ServerId for Server %s", staticConfig.SERVER_NAME.c_str() );
|
||||
}
|
||||
mysql_free_result( result );
|
||||
|
||||
} // end if has SERVER_NAME
|
||||
} else if ( staticConfig.SERVER_NAME.empty() ) {
|
||||
|
|
|
@ -95,7 +95,7 @@ MYSQL_RES * zmDbFetch( const char * query ) {
|
|||
return result;
|
||||
} // end MYSQL_RES * zmDbFetch( const char * query );
|
||||
|
||||
MYSQL_ROW zmDBFetchOne( const char *query ) {
|
||||
MYSQL_ROW zmDbFetchOne( const char *query ) {
|
||||
MYSQL_RES *result = zmDbFetch( query );
|
||||
int n_rows = mysql_num_rows( result );
|
||||
if ( n_rows != 1 ) {
|
||||
|
@ -104,6 +104,7 @@ MYSQL_ROW zmDBFetchOne( const char *query ) {
|
|||
}
|
||||
|
||||
MYSQL_ROW dbrow = mysql_fetch_row( result );
|
||||
mysql_free_result( result );
|
||||
if ( ! dbrow ) {
|
||||
Error("Error getting row from query %s. Error is %s", query, mysql_error( &dbconn ) );
|
||||
return NULL;
|
||||
|
|
|
@ -33,7 +33,7 @@ void zmDbConnect();
|
|||
void zmDbClose();
|
||||
|
||||
MYSQL_RES * zmDbFetch( const char *query );
|
||||
MYSQL_ROW zmDBFetchOne( const char *query );
|
||||
MYSQL_ROW zmDbFetchOne( const char *query );
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
|
Loading…
Reference in New Issue