当前位置: 首页>>代码示例>>C++>>正文


C++ QueryResultMysql类代码示例

本文整理汇总了C++中QueryResultMysql的典型用法代码示例。如果您正苦于以下问题:C++ QueryResultMysql类的具体用法?C++ QueryResultMysql怎么用?C++ QueryResultMysql使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QueryResultMysql类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: query_connection_guard

QueryResult* DatabaseMysql::Query(const char *sql)
{
    if (!mMysql)
        return 0;

    MYSQL_RES *result = 0;
    uint64 rowCount = 0;
    uint32 fieldCount = 0;

    {
        // guarded block for thread-safe mySQL request
        ZThread::Guard<ZThread::FastMutex> query_connection_guard(mMutex);
        #ifdef MANGOS_DEBUG
        uint32 _s = getMSTime();
        #endif
        if(mysql_query(mMysql, sql))
        {
            sLog.outErrorDb( "SQL: %s", sql );
            sLog.outErrorDb("query ERROR: %s", mysql_error(mMysql));
            return NULL;
        }
        else
        {
            #ifdef MANGOS_DEBUG
            sLog.outDebug("[%u ms] SQL: %s", getMSTimeDiff(_s,getMSTime()), sql );
            #endif
        }

        result = mysql_store_result(mMysql);

        rowCount = mysql_affected_rows(mMysql);
        fieldCount = mysql_field_count(mMysql);
        // end guarded block
    }

    if (!result )
        return NULL;

    if (!rowCount)
    {
        mysql_free_result(result);
        return NULL;
    }

    QueryResultMysql *queryResult = new QueryResultMysql(result, rowCount, fieldCount);

    queryResult->NextRow();

    return queryResult;
}
开发者ID:Actionfox,项目名称:mangos,代码行数:50,代码来源:DatabaseMysql.cpp

示例2: QueryResultMysql

QueryResult* MySQLConnection::Query(const char *sql)
{
    MYSQL_RES *result = NULL;
    MYSQL_FIELD *fields = NULL;
    uint64 rowCount = 0;
    uint32 fieldCount = 0;

    if(!_Query(sql,&result,&fields,&rowCount,&fieldCount))
        return NULL;

    QueryResultMysql *queryResult = new QueryResultMysql(result, fields, rowCount, fieldCount);

    queryResult->NextRow();
    return queryResult;
}
开发者ID:gc,项目名称:mangos,代码行数:15,代码来源:DatabaseMysql.cpp

示例3: QueryResult_AutoPtr

QueryResult_AutoPtr DatabaseMysql::Query(const char *sql)
{
    MYSQL_RES *result = NULL;
    MYSQL_FIELD *fields = NULL;
    uint64 rowCount = 0;
    uint32 fieldCount = 0;

    if (!_Query(sql, &result, &fields, &rowCount, &fieldCount))
        return QueryResult_AutoPtr(NULL);

    QueryResultMysql *queryResult = new QueryResultMysql(result, fields, rowCount, fieldCount);

    queryResult->NextRow();

    return QueryResult_AutoPtr(queryResult);
}
开发者ID:Elevim,项目名称:RG-332,代码行数:16,代码来源:DatabaseMysql.cpp

示例4: query_connection_guard

QueryResult* DatabaseMysql::Query(const char *sql)
{
    if (!mMysql)
        return 0;

    MYSQL_RES *result = 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));

        if(mysql_query(mMysql, sql))
        {
            sLog.outError( "SQL: %s", sql );
            sLog.outError("query ERROR: %s", mysql_error(mMysql));
            return NULL;
        }
        else
        {
            DEBUG_LOG( "SQL: %s", sql );
        }

        result = mysql_store_result(mMysql);

        rowCount = mysql_affected_rows(mMysql);
        fieldCount = mysql_field_count(mMysql);
        // end guarded block
    }

    if (!result )
        return NULL;

    if (!rowCount)
    {
        mysql_free_result(result);
        return NULL;
    }

    QueryResultMysql *queryResult = new QueryResultMysql(result, rowCount, fieldCount);

    queryResult->NextRow();

    return queryResult;
}
开发者ID:Aion,项目名称:caldari,代码行数:46,代码来源:DatabaseMysql.cpp

示例5: getMSTime

QueryResult* DatabaseMysql::QueryStrict(const char *sql)
{
    if (!mMysql)
        return 0;

    MYSQL_RES *result = 0;
    uint64 rowCount = 0;
    uint32 fieldCount = 0;

    {
        // guarded block for thread-safe mySQL request
        //ZThread::Guard<ZThread::FastMutex> query_connection_guard(mMutex);
		//I dont want do make this thread safe yet~I mean no need now. By YinQing
#ifdef MANGOS_DEBUG
        uint32 _s = getMSTime();
#endif
        if(mysql_query(mMysql, sql))
        {
        	IME_SQLERROR("SQL: %s", sql);
        	IME_SQLERROR("query ERROR: %s", mysql_error(mMysql));
            return NULL;
        }
        else
        {
#ifdef MANGOS_DEBUG
        	IME_SQLERROR("[%u ms] SQL: %s", getMSTime() - _s, sql );
#endif
        }

        result = mysql_store_result(mMysql);

        rowCount = mysql_affected_rows(mMysql);
        fieldCount = mysql_field_count(mMysql);
        // end guarded block
    }

    if (!result )
        return NULL;

    QueryResultMysql *queryResult = new QueryResultMysql(result, rowCount, fieldCount);

    queryResult->NextRow();

    return queryResult;
}
开发者ID:imane-jym,项目名称:gp,代码行数:45,代码来源:DatabaseMysql.cpp

示例6: names

QueryNamedResult* MySQLConnection::QueryNamed(const char *sql)
{
    MYSQL_RES *result = NULL;
    MYSQL_FIELD *fields = NULL;
    uint64 rowCount = 0;
    uint32 fieldCount = 0;

    if(!_Query(sql,&result,&fields,&rowCount,&fieldCount))
        return NULL;

    QueryFieldNames names(fieldCount);
    for (uint32 i = 0; i < fieldCount; i++)
        names[i] = fields[i].name;

    QueryResultMysql *queryResult = new QueryResultMysql(result, fields, rowCount, fieldCount);

    queryResult->NextRow();
    return new QueryNamedResult(queryResult,names);
}
开发者ID:gc,项目名称:mangos,代码行数:19,代码来源:DatabaseMysql.cpp


注:本文中的QueryResultMysql类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。