예제 #1
0
//-------------------------------------------------------------------------------------
bool DBInterfaceMysql::query(const char* cmd, uint32 size, bool showExecInfo, MemoryStream * result)
{
	if(pMysql_ == NULL)
	{
		if(showExecInfo)
		{
			ERROR_MSG(fmt::format("DBInterfaceMysql::query: has no attach(db).sql:({})\n", lastquery_));
		}

		if(result)
			write_query_result(result);

		return false;
	}

	querystatistics(cmd, size);

	lastquery_.assign(cmd, size);

	if(_g_debug)
	{
		DEBUG_MSG(fmt::format("DBInterfaceMysql::query({:p}): {}\n", (void*)this, lastquery_));
	}

    int nResult = mysql_real_query(pMysql_, cmd, size);  

    if(nResult != 0)  
    {
		if(showExecInfo)
		{
			ERROR_MSG(fmt::format("DBInterfaceMysql::query: is error({}:{})!\nsql:({})\n", 
				mysql_errno(pMysql_), mysql_error(pMysql_), lastquery_)); 
		}

		this->throwError();
		
		if(result)
			write_query_result(result);

        return false;
    } 
    else
    {
		if(showExecInfo)
		{
			INFO_MSG("DBInterfaceMysql::query: successfully!\n"); 
		}
    }

    return result == NULL || write_query_result(result);
}
예제 #2
0
//-------------------------------------------------------------------------------------
bool DBInterfaceMysql::query(const char* strCommand, uint32 size, bool showexecinfo)
{
	if(pMysql_ == NULL)
	{
		if(showexecinfo)
		{
			ERROR_MSG(boost::format("DBInterfaceMysql::query: has no attach(db).sql:(%1%)\n") % lastquery_);
		}

		return false;
	}

	querystatistics(strCommand, size);

	lastquery_ = strCommand;

	if(_g_debug)
	{
		DEBUG_MSG(boost::format("DBInterfaceMysql::query(%1%): %2%\n") % this % lastquery_);
	}

    int nResult = mysql_real_query(pMysql_, strCommand, size);  

    if(nResult != 0)  
    {  
		if(showexecinfo)
		{
			ERROR_MSG(boost::format("DBInterfaceMysql::query: is error(%1%:%2%)!\nsql:(%3%)\n") % 
				mysql_errno(pMysql_) % mysql_error(pMysql_) % lastquery_); 
		}

		this->throwError();
        return false;
    }  
    else
    {
		if(showexecinfo)
		{
			INFO_MSG("DBInterfaceMysql::query: successfully!\n"); 
		}
    }
    
    return true;
}
예제 #3
0
//-------------------------------------------------------------------------------------
bool DBInterfaceMysql::query(const char* strCommand, uint32 size, bool showexecinfo)
{
	if(pMysql_ == NULL)
	{
		if(showexecinfo)
		{
			ERROR_MSG(fmt::format("DBInterfaceMysql::query: has no attach(db).sql:({})\n", lastquery_));
		}

		return false;
	}

	querystatistics(strCommand, size);

	lastquery_ = strCommand;

	if(_g_debug)
	{
		DEBUG_MSG(fmt::format("DBInterfaceMysql::query({:p}): {}\n", (void*)this, lastquery_));
	}

    int nResult = mysql_real_query(pMysql_, strCommand, size);  

    if(nResult != 0)  
    {  
		if(showexecinfo)
		{
			ERROR_MSG(fmt::format("DBInterfaceMysql::query: is error({}:{})!\nsql:({})\n", 
				mysql_errno(pMysql_), mysql_error(pMysql_), lastquery_)); 
		}

		this->throwError();
        return false;
    }  
    else
    {
		if(showexecinfo)
		{
			INFO_MSG("DBInterfaceMysql::query: successfully!\n"); 
		}
    }
    
    return true;
}