mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-21 10:11:30 +00:00
Added FieldName for column name requests
This commit is contained in:
parent
d514eef59b
commit
923adc3ea5
@ -32,10 +32,11 @@ MySQLRequestResult::MySQLRequestResult(MYSQL_RES* result, uint32 rowsAffected, u
|
|||||||
m_RowsAffected = rowsAffected;
|
m_RowsAffected = rowsAffected;
|
||||||
m_RowCount = rowCount;
|
m_RowCount = rowCount;
|
||||||
m_ColumnCount = columnCount;
|
m_ColumnCount = columnCount;
|
||||||
// If we actually need the column length it will be requested
|
// If we actually need the column length / fields it will be
|
||||||
// at that time, no need to pull it in just to cache it.
|
// requested at that time, no need to pull it in just to cache it.
|
||||||
// Normal usage would have it as nullptr most likely anyways.
|
// Normal usage would have it as nullptr most likely anyways.
|
||||||
m_ColumnLengths = nullptr;
|
m_ColumnLengths = nullptr;
|
||||||
|
m_Fields = nullptr;
|
||||||
m_LastInsertedID = lastInsertedID;
|
m_LastInsertedID = lastInsertedID;
|
||||||
m_ErrorNumber = errorNumber;
|
m_ErrorNumber = errorNumber;
|
||||||
}
|
}
|
||||||
@ -56,6 +57,7 @@ void MySQLRequestResult::ZeroOut()
|
|||||||
m_Result = nullptr;
|
m_Result = nullptr;
|
||||||
m_ErrorBuffer = nullptr;
|
m_ErrorBuffer = nullptr;
|
||||||
m_ColumnLengths = nullptr;
|
m_ColumnLengths = nullptr;
|
||||||
|
m_Fields = nullptr;
|
||||||
m_RowCount = 0;
|
m_RowCount = 0;
|
||||||
m_RowsAffected = 0;
|
m_RowsAffected = 0;
|
||||||
m_LastInsertedID = 0;
|
m_LastInsertedID = 0;
|
||||||
@ -88,6 +90,17 @@ uint32 MySQLRequestResult::LengthOfColumn(int columnIndex)
|
|||||||
return m_ColumnLengths[columnIndex];
|
return m_ColumnLengths[columnIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::string MySQLRequestResult::FieldName(int columnIndex)
|
||||||
|
{
|
||||||
|
if (columnIndex >= m_ColumnCount || m_Result == nullptr)
|
||||||
|
return std::string();
|
||||||
|
|
||||||
|
if (m_Fields == nullptr)
|
||||||
|
m_Fields = mysql_fetch_fields(m_Result);
|
||||||
|
|
||||||
|
return std::string(m_Fields[columnIndex].name);
|
||||||
|
}
|
||||||
|
|
||||||
MySQLRequestResult::MySQLRequestResult(MySQLRequestResult&& moveItem)
|
MySQLRequestResult::MySQLRequestResult(MySQLRequestResult&& moveItem)
|
||||||
: m_CurrentRow(moveItem.m_CurrentRow), m_OneBeyondRow()
|
: m_CurrentRow(moveItem.m_CurrentRow), m_OneBeyondRow()
|
||||||
{
|
{
|
||||||
@ -98,6 +111,7 @@ MySQLRequestResult::MySQLRequestResult(MySQLRequestResult&& moveItem)
|
|||||||
m_RowsAffected = moveItem.m_RowsAffected;
|
m_RowsAffected = moveItem.m_RowsAffected;
|
||||||
m_LastInsertedID = moveItem.m_LastInsertedID;
|
m_LastInsertedID = moveItem.m_LastInsertedID;
|
||||||
m_ColumnLengths = moveItem.m_ColumnLengths;
|
m_ColumnLengths = moveItem.m_ColumnLengths;
|
||||||
|
m_Fields = moveItem.m_Fields;
|
||||||
|
|
||||||
// Keeps deconstructor from double freeing
|
// Keeps deconstructor from double freeing
|
||||||
// pre move instance.
|
// pre move instance.
|
||||||
@ -124,6 +138,7 @@ MySQLRequestResult& MySQLRequestResult::operator=(MySQLRequestResult&& other)
|
|||||||
m_CurrentRow = other.m_CurrentRow;
|
m_CurrentRow = other.m_CurrentRow;
|
||||||
m_OneBeyondRow = other.m_OneBeyondRow;
|
m_OneBeyondRow = other.m_OneBeyondRow;
|
||||||
m_ColumnLengths = other.m_ColumnLengths;
|
m_ColumnLengths = other.m_ColumnLengths;
|
||||||
|
m_Fields = other.m_Fields;
|
||||||
|
|
||||||
// Keeps deconstructor from double freeing
|
// Keeps deconstructor from double freeing
|
||||||
// pre move instance.
|
// pre move instance.
|
||||||
|
|||||||
@ -16,6 +16,7 @@
|
|||||||
class MySQLRequestResult {
|
class MySQLRequestResult {
|
||||||
private:
|
private:
|
||||||
MYSQL_RES* m_Result;
|
MYSQL_RES* m_Result;
|
||||||
|
MYSQL_FIELD* m_Fields;
|
||||||
char* m_ErrorBuffer;
|
char* m_ErrorBuffer;
|
||||||
unsigned long* m_ColumnLengths;
|
unsigned long* m_ColumnLengths;
|
||||||
MySQLRequestRow m_CurrentRow;
|
MySQLRequestRow m_CurrentRow;
|
||||||
@ -47,6 +48,7 @@ public:
|
|||||||
uint32 LastInsertedID() const {return m_LastInsertedID;}
|
uint32 LastInsertedID() const {return m_LastInsertedID;}
|
||||||
// default to 0 index since we mostly use it that way anyways.
|
// default to 0 index since we mostly use it that way anyways.
|
||||||
uint32 LengthOfColumn(int columnIndex = 0);
|
uint32 LengthOfColumn(int columnIndex = 0);
|
||||||
|
const std::string FieldName(int columnIndex);
|
||||||
|
|
||||||
MySQLRequestRow& begin() { return m_CurrentRow; }
|
MySQLRequestRow& begin() { return m_CurrentRow; }
|
||||||
MySQLRequestRow& end() { return m_OneBeyondRow;}
|
MySQLRequestRow& end() { return m_OneBeyondRow;}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user