|
@@ -312,22 +312,52 @@ int MSDatenbank::suchErhaltungServer( unsigned int client )
|
|
|
|
|
|
int MSDatenbank::suchShopServer( unsigned int client )
|
|
int MSDatenbank::suchShopServer( unsigned int client )
|
|
{
|
|
{
|
|
- Text *befehl = new Text( "SELECT such_server( " );
|
|
|
|
- befehl->append( client );
|
|
|
|
- befehl->append( ", 'shop' )" );
|
|
|
|
|
|
+ Text befehl = "SELECT server_id FROM server_client a, server b WHERE a.server_id = b.id AND b.server_typ_name = 'shop' AND a.client_id = ";
|
|
|
|
+ befehl += (int)client;
|
|
|
|
+ lock();
|
|
|
|
+ if( !datenbank->befehl( befehl ) )
|
|
|
|
+ {
|
|
|
|
+ unlock();
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ Result res = datenbank->getResult();
|
|
|
|
+ unlock();
|
|
|
|
+ if( res.zeilenAnzahl )
|
|
|
|
+ {
|
|
|
|
+ int ret = res.values[ 0 ];
|
|
|
|
+ res.destroy();
|
|
|
|
+ return ret;
|
|
|
|
+ }
|
|
|
|
+ res.destroy();
|
|
|
|
+ lock();
|
|
|
|
+ if( !datenbank->befehl( "SELECT a.id, count( b.client_id ) AS anz FROM server a, server_client b WHERE a.id = b.server_id AND a.server_typ_name = 'shop' AND a.server_status_id = 3 GROUP BY a.id ORDER BY anz LIMIT 1" ) )
|
|
|
|
+ {
|
|
|
|
+ unlock();
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ Result res = datenbank->getResult();
|
|
|
|
+ unlock();
|
|
|
|
+ if( !res.zeilenAnzahl )
|
|
|
|
+ {
|
|
|
|
+ unlock();
|
|
|
|
+ res.destroy();
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ int id = res.values[ 0 ];
|
|
|
|
+ res.destroy();
|
|
|
|
+ befehl = "INSERT INTO server_client( client_id, server_id ) VALUES ( ";
|
|
|
|
+ befehl += (int)client;
|
|
|
|
+ befehl += ", ";
|
|
|
|
+ befehl += id;
|
|
|
|
+ befehl += " )";
|
|
lock();
|
|
lock();
|
|
- if( !datenbank->befehl( befehl->getText() ) )
|
|
|
|
|
|
+ if( !datenbank->befehl( befehl ) )
|
|
{
|
|
{
|
|
unlock();
|
|
unlock();
|
|
- befehl->release();
|
|
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
- befehl->release();
|
|
|
|
- Result res = datenbank->getResult();
|
|
|
|
unlock();
|
|
unlock();
|
|
- int ret = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
|
- res.destroy();
|
|
|
|
- return ret;
|
|
|
|
|
|
+ return id;
|
|
}
|
|
}
|
|
|
|
|
|
int MSDatenbank::suchNewsServer( unsigned int client )
|
|
int MSDatenbank::suchNewsServer( unsigned int client )
|