mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-28 07:58:08 +01:00
get public rooms from the db rather than stubbing it out.
This commit is contained in:
parent
be23e06b60
commit
e06baf566f
1 changed files with 21 additions and 3 deletions
|
@ -228,9 +228,27 @@ DBMgr::ClearCIDs( void )
|
|||
void
|
||||
DBMgr::PublicRooms( int lang, int nPlayers, int* nNames, string& names )
|
||||
{
|
||||
*nNames = 2;
|
||||
names.append( "hello world/2\n" );
|
||||
names.append( "Room 222/1\n" );
|
||||
int ii;
|
||||
int nTuples;
|
||||
|
||||
const char* fmt = "SELECT room, nTotal-nJoined FROM " TABLE_NAME
|
||||
" WHERE ispublic = TRUE AND lang = %d AND ntotal =% d";
|
||||
|
||||
char query[256];
|
||||
snprintf( query, sizeof(query), fmt, lang, nPlayers );
|
||||
logf( XW_LOGINFO, "%s: query: %s", __func__, query );
|
||||
|
||||
MutexLock ml( &m_dbMutex );
|
||||
|
||||
PGresult* result = PQexec( m_pgconn, query );
|
||||
nTuples = PQntuples( result );
|
||||
for ( ii = 0; ii < nTuples; ++ii ) {
|
||||
names.append( PQgetvalue( result, ii, 0 ) );
|
||||
names.append( "/" );
|
||||
names.append( PQgetvalue( result, ii, 1 ) );
|
||||
}
|
||||
PQclear( result );
|
||||
*nNames = nTuples;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Add table
Reference in a new issue