本文整理汇总了C++中QueryResultPostgre::NextRow方法的典型用法代码示例。如果您正苦于以下问题:C++ QueryResultPostgre::NextRow方法的具体用法?C++ QueryResultPostgre::NextRow怎么用?C++ QueryResultPostgre::NextRow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueryResultPostgre
的用法示例。
在下文中一共展示了QueryResultPostgre::NextRow方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Query
QueryResult* DatabasePostgre::Query(const char *sql)
{
if (!mPGconn)
return 0;
uint64 rowCount = 0;
uint32 fieldCount = 0;
// guarded block for thread-safe mySQL request
ZThread::Guard<ZThread::FastMutex> query_connection_guard((ZThread::ThreadImpl::current()==tranThread?tranMutex:mMutex));
// Send the query
PGresult * result = PQexec(mPGconn, sql);
if (PQresultStatus(result) != PGRES_COMMAND_OK)
{
sLog.outErrorDb( "SQL: %s", sql );
sLog.outErrorDb("query ERROR: %s", PQerrorMessage(mPGconn));
PQclear(result);
return NULL;
}
else
{
DEBUG_LOG( "SQL: %s", sql );
}
rowCount = PQntuples(result);
fieldCount = PQnfields(result);
// end guarded block
if (!result )
{
PQclear(result);
return NULL;
}
if (!rowCount)
{
PQclear(result);
return NULL;
}
QueryResultPostgre * queryResult = new QueryResultPostgre(result, fieldCount, rowCount);
return queryResult;
queryResult->NextRow();
return queryResult;
}
示例2: Query
QueryResult* DatabasePostgre::Query(const char *sql)
{
if (!mPGconn)
return 0;
uint64 rowCount = 0;
uint32 fieldCount = 0;
// guarded block for thread-safe request
ACE_Guard<ACE_Thread_Mutex> query_connection_guard(mMutex);
#ifdef MANGOS_DEBUG
uint32 _s = getMSTime();
#endif
// Send the query
PGresult * result = PQexec(mPGconn, sql);
if (!result )
{
return NULL;
}
if (PQresultStatus(result) != PGRES_TUPLES_OK)
{
sLog.outErrorDb( "SQL : %s", sql );
sLog.outErrorDb( "SQL %s", PQerrorMessage(mPGconn));
PQclear(result);
return NULL;
}
else
{
#ifdef MANGOS_DEBUG
sLog.outDebug("[%u ms] SQL: %s", getMSTime() - _s, sql );
#endif
}
rowCount = PQntuples(result);
fieldCount = PQnfields(result);
// end guarded block
if (!rowCount)
{
PQclear(result);
return NULL;
}
QueryResultPostgre * queryResult = new QueryResultPostgre(result, rowCount, fieldCount);
queryResult->NextRow();
return queryResult;
}
示例3: Query
QueryResult* PostgreSQLConnection::Query(const char* sql)
{
if (!mPGconn)
return NULL;
PGresult* result = NULL;
uint64 rowCount = 0;
uint32 fieldCount = 0;
if (!_Query(sql, &result, &rowCount, &fieldCount))
return NULL;
QueryResultPostgre* queryResult = new QueryResultPostgre(result, rowCount, fieldCount);
queryResult->NextRow();
return queryResult;
}
示例4: QueryNamed
QueryNamedResult* PostgreSQLConnection::QueryNamed(const char* sql)
{
if (!mPGconn)
return NULL;
PGresult* result = NULL;
uint64 rowCount = 0;
uint32 fieldCount = 0;
if (!_Query(sql, &result, &rowCount, &fieldCount))
return NULL;
QueryFieldNames names(fieldCount);
for (uint32 i = 0; i < fieldCount; ++i)
names[i] = PQfname(result, i);
QueryResultPostgre* queryResult = new QueryResultPostgre(result, rowCount, fieldCount);
queryResult->NextRow();
return new QueryNamedResult(queryResult, names);
}