本文整理汇总了C++中DBerror::GetErrNo方法的典型用法代码示例。如果您正苦于以下问题:C++ DBerror::GetErrNo方法的具体用法?C++ DBerror::GetErrNo怎么用?C++ DBerror::GetErrNo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBerror
的用法示例。
在下文中一共展示了DBerror::GetErrNo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoQuery_locked
bool DBcore::DoQuery_locked(DBerror &err, const char *query, int32 querylen, bool retry)
{
if (pStatus != Connected)
Open_locked();
if (mysql_real_query(&mysql, query, querylen)) {
int num = mysql_errno(&mysql);
if (num == CR_SERVER_GONE_ERROR)
pStatus = Error;
if (retry && (num == CR_SERVER_LOST || num == CR_SERVER_GONE_ERROR))
{
sLog.Error("DBCore", "Lost connection, attempting to recover....");
return DoQuery_locked(err, query, querylen, false);
}
pStatus = Error;
err.SetError(num, mysql_error(&mysql));
sLog.Error("DBCore Query", "#%d in '%s': %s", err.GetErrNo(), query, err.c_str());
return false;
}
err.ClearError();
return true;
}
示例2: RunQuery
bool DBcore::RunQuery(const char* query, int32 querylen, char* errbuf, MYSQL_RES** result, int32* affected_rows, int32* last_insert_id, int32* errnum, bool retry) {
if (errnum)
*errnum = 0;
if (errbuf)
errbuf[0] = 0;
MutexLock lock(MDatabase);
DBerror err;
if(!DoQuery_locked(err, query, querylen, retry))
{
sLog.Error("DBCore Query", "Query: %s failed", query);
if(errnum != NULL)
*errnum = err.GetErrNo();
/* @note possible buffer overflow because the size of 'errbuf' is unknown.
* @todo check if this function is actualy used and of so... change the strcpy to strncpy.
*/
if(errbuf != NULL)
strcpy(errbuf, err.c_str());
return false;
}
if (result) {
if(mysql_field_count(&mysql)) {
*result = mysql_store_result(&mysql);
} else {
*result = NULL;
if (errnum)
*errnum = UINT_MAX;
/* @note possible buffer overflow because the size of 'errbuf' is unknown.
* @todo check if this function is actualy used and of so... change the strcpy to strncpy.
*/
if (errbuf)
strcpy(errbuf, "DBcore::RunQuery: No Result");
sLog.Error("DBCore Query", "Query: %s failed because it should return a result", query);
return false;
}
}
if (affected_rows)
*affected_rows = (uint32)mysql_affected_rows(&mysql);
if (last_insert_id)
*last_insert_id = (uint32)mysql_insert_id(&mysql);
return true;
}