mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-05 20:45:49 +01:00
simplify construction of one query
This commit is contained in:
parent
becbf7aea6
commit
9efb044c4f
1 changed files with 9 additions and 23 deletions
|
@ -396,32 +396,18 @@ DBMgr::RegisterDevice( const DevID* host, int clientVersion,
|
||||||
devID = (DevIDRelay)random();
|
devID = (DevIDRelay)random();
|
||||||
} while ( DEVID_NONE == devID );
|
} while ( DEVID_NONE == devID );
|
||||||
|
|
||||||
const char* command = "INSERT INTO " DEVICES_TABLE
|
StrWPF query;
|
||||||
" (id, devTypes[1], devids[1], clntVers, versDesc, model, osvers)"
|
query.catf( "INSERT INTO " DEVICES_TABLE " (id, devTypes[1],"
|
||||||
" VALUES( $1, $2, $3, $4, $5, $6, $7 )";
|
" devids[1], clntVers, versdesc, model, osvers)"
|
||||||
int nParams = 7;
|
" VALUES( %d, %d, '%s', %d, '%s', '%s', '%s' )",
|
||||||
char* paramValues[nParams];
|
devID, host->m_devIDType, devidStr, clientVersion,
|
||||||
char buf[1024];
|
desc, model, osVers );
|
||||||
formatParams( paramValues, nParams,
|
logf( XW_LOGINFO, "%s: %s", __func__, query.c_str() );
|
||||||
"%d"DELIM"%d"DELIM"%s"DELIM"%d"DELIM"%s"DELIM"%s"DELIM"%s",
|
success = execSql( query );
|
||||||
buf, sizeof(buf), devID, host->m_devIDType,
|
|
||||||
devidStr, clientVersion, desc, model, osVers );
|
|
||||||
|
|
||||||
PGresult* result = PQexecParams( getThreadConn(), command,
|
|
||||||
nParams, NULL,
|
|
||||||
paramValues,
|
|
||||||
NULL, NULL, 0 );
|
|
||||||
success = PGRES_COMMAND_OK == PQresultStatus(result);
|
|
||||||
if ( !success ) {
|
|
||||||
logf( XW_LOGERROR, "%s: PQexec=>%s;%s", __func__,
|
|
||||||
PQresStatus(PQresultStatus(result)),
|
|
||||||
PQresultErrorMessage(result) );
|
|
||||||
}
|
|
||||||
PQclear( result );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return devID;
|
return devID;
|
||||||
}
|
} // RegisterDevice
|
||||||
|
|
||||||
DevIDRelay
|
DevIDRelay
|
||||||
DBMgr::RegisterDevice( const DevID* host )
|
DBMgr::RegisterDevice( const DevID* host )
|
||||||
|
|
Loading…
Add table
Reference in a new issue