TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ResultSet Class Reference

#include <QueryResult.h>

Public Member Functions

 ResultSet (MYSQL_RES *result, MYSQL_FIELD *fields, uint64 rowCount, uint32 fieldCount)
 
 ~ResultSet ()
 
bool NextRow ()
 
uint64 GetRowCount () const
 
uint32 GetFieldCount () const
 
FieldFetch () const
 
const Fieldoperator[] (uint32 index) const
 

Protected Attributes

uint64 _rowCount
 
Field_currentRow
 
uint32 _fieldCount
 

Private Member Functions

void CleanUp ()
 
 ResultSet (ResultSet const &right)=delete
 
ResultSetoperator= (ResultSet const &right)=delete
 

Private Attributes

MYSQL_RES * _result
 
MYSQL_FIELD * _fields
 

Constructor & Destructor Documentation

ResultSet::ResultSet ( MYSQL_RES *  result,
MYSQL_FIELD *  fields,
uint64  rowCount,
uint32  fieldCount 
)
22  :
23 _rowCount(rowCount),
24 _fieldCount(fieldCount),
25 _result(result),
26 _fields(fields)
27 {
29 #ifdef TRINITY_DEBUG
30  for (uint32 i = 0; i < _fieldCount; i++)
31  _currentRow[i].SetMetadata(&_fields[i], i);
32 #endif
33 }
MYSQL_RES * _result
Definition: QueryResult.h:54
MYSQL_FIELD * _fields
Definition: QueryResult.h:55
Class used to access individual fields of database query result.
Definition: Field.h:56
uint32 _fieldCount
Definition: QueryResult.h:50
uint32_t uint32
Definition: Define.h:150
Field * _currentRow
Definition: QueryResult.h:49
uint64 _rowCount
Definition: QueryResult.h:48
ResultSet::~ResultSet ( )
167 {
168  CleanUp();
169 }
void CleanUp()
Definition: QueryResult.cpp:225

+ Here is the call graph for this function:

ResultSet::ResultSet ( ResultSet const right)
privatedelete

Member Function Documentation

void ResultSet::CleanUp ( )
private
226 {
227  if (_currentRow)
228  {
229  delete [] _currentRow;
230  _currentRow = NULL;
231  }
232 
233  if (_result)
234  {
235  mysql_free_result(_result);
236  _result = NULL;
237  }
238 }
MYSQL_RES * _result
Definition: QueryResult.h:54
arena_t NULL
Definition: jemalloc_internal.h:624
Field * _currentRow
Definition: QueryResult.h:49

+ Here is the caller graph for this function:

Field* ResultSet::Fetch ( ) const
inline
40 { return _currentRow; }
Field * _currentRow
Definition: QueryResult.h:49
uint32 ResultSet::GetFieldCount ( ) const
inline
38 { return _fieldCount; }
uint32 _fieldCount
Definition: QueryResult.h:50
uint64 ResultSet::GetRowCount ( ) const
inline
37 { return _rowCount; }
uint64 _rowCount
Definition: QueryResult.h:48

+ Here is the caller graph for this function:

bool ResultSet::NextRow ( )
177 {
178  MYSQL_ROW row;
179 
180  if (!_result)
181  return false;
182 
183  row = mysql_fetch_row(_result);
184  if (!row)
185  {
186  CleanUp();
187  return false;
188  }
189 
190  unsigned long* lengths = mysql_fetch_lengths(_result);
191  if (!lengths)
192  {
193  TC_LOG_WARN("sql.sql", "%s:mysql_fetch_lengths, cannot retrieve value lengths. Error %s.", __FUNCTION__, mysql_error(_result->handle));
194  CleanUp();
195  return false;
196  }
197 
198  for (uint32 i = 0; i < _fieldCount; i++)
199  _currentRow[i].SetStructuredValue(row[i], _fields[i].type, lengths[i]);
200 
201  return true;
202 }
MYSQL_RES * _result
Definition: QueryResult.h:54
MYSQL_FIELD * _fields
Definition: QueryResult.h:55
uint32 _fieldCount
Definition: QueryResult.h:50
uint32_t uint32
Definition: Define.h:150
Field * _currentRow
Definition: QueryResult.h:49
#define TC_LOG_WARN(filterType__,...)
Definition: Log.h:204
void CleanUp()
Definition: QueryResult.cpp:225

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ResultSet& ResultSet::operator= ( ResultSet const right)
privatedelete
const Field& ResultSet::operator[] ( uint32  index) const
inline
42  {
43  ASSERT(index < _fieldCount);
44  return _currentRow[index];
45  }
uint32 _fieldCount
Definition: QueryResult.h:50
Field * _currentRow
Definition: QueryResult.h:49
#define ASSERT
Definition: Errors.h:55

Member Data Documentation

Field* ResultSet::_currentRow
protected
uint32 ResultSet::_fieldCount
protected
MYSQL_FIELD* ResultSet::_fields
private
MYSQL_RES* ResultSet::_result
private
uint64 ResultSet::_rowCount
protected

The documentation for this class was generated from the following files: