本文整理汇总了C++中QueryResultPostgre类的典型用法代码示例。如果您正苦于以下问题:C++ QueryResultPostgre类的具体用法?C++ QueryResultPostgre怎么用?C++ QueryResultPostgre使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QueryResultPostgre类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: query_connection_guard
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_connection_guard
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: QueryResultPostgre
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: names
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);
}