The InspIRCd Project
Home | Developers | Wiki | Forums | Bug Tracker | SVN | Download
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

MySQLresult Class Reference

Represents a mysql result set. More...

Inheritance diagram for MySQLresult:

Inheritance graph
[legend]
Collaboration diagram for MySQLresult:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 MySQLresult (Module *self, Module *to, MYSQL_RES *res, int affected_rows, unsigned int rid)
 MySQLresult (Module *self, Module *to, SQLerror e, unsigned int rid)
 ~MySQLresult ()
virtual int Rows ()
 Return the number of rows in the result Note that if you have perfomed an INSERT or UPDATE query or other query which will not return rows, this will return the number of affected rows, and SQLresult::Cols() will contain 0.
virtual int Cols ()
 Return the number of columns in the result.
virtual std::string ColName (int column)
 Get a string name of the column by an index number.
virtual int ColNum (const std::string &column)
 Get an index number for a column from a string name.
virtual SQLfield GetValue (int row, int column)
 Get a string value in a given row and column This does not effect the internal cursor.
virtual SQLfieldListGetRow ()
 Return a list of values in a row, this should increment an internal counter so you can repeatedly call it until it returns an empty vector.
virtual SQLfieldMapGetRowMap ()
 As above, but return a map indexed by key name.
virtual SQLfieldListGetRowPtr ()
 Like GetRow(), but returns a pointer to a dynamically allocated object which must be explicitly freed.
virtual SQLfieldMapGetRowMapPtr ()
 As above, but return a map indexed by key name The internal cursor (row counter) is incremented by one.
virtual void Free (SQLfieldMap *fm)
 Overloaded function for freeing the lists and maps returned by GetRowPtr or GetRowMapPtr.
virtual void Free (SQLfieldList *fl)
 Overloaded function for freeing the lists and maps returned by GetRowPtr or GetRowMapPtr.

Private Attributes

int currentrow
std::vector< std::stringcolnames
std::vector< SQLfieldListfieldlists
SQLfieldMapfieldmap
SQLfieldMap fieldmap2
SQLfieldList emptyfieldlist
int rows

Detailed Description

Represents a mysql result set.

Definition at line 111 of file m_mysql.cpp.


Constructor & Destructor Documentation

MySQLresult::MySQLresult Module self,
Module to,
MYSQL_RES *  res,
int  affected_rows,
unsigned int  rid
[inline]
 

Definition at line 122 of file m_mysql.cpp.

References colnames, fieldlists, and rows.

MySQLresult::MySQLresult Module self,
Module to,
SQLerror  e,
unsigned int  rid
[inline]
 

Definition at line 168 of file m_mysql.cpp.

References SQLresult::error, and rows.

MySQLresult::~MySQLresult  )  [inline]
 

Definition at line 174 of file m_mysql.cpp.


Member Function Documentation

virtual std::string MySQLresult::ColName int  column  )  [inline, virtual]
 

Get a string name of the column by an index number.

Parameters:
column The id number of a column
Returns:
The column name associated with the given ID

Implements SQLresult.

Definition at line 188 of file m_mysql.cpp.

References colnames.

virtual int MySQLresult::ColNum const std::string column  )  [inline, virtual]
 

Get an index number for a column from a string name.

An exception of type SQLbadColName will be thrown if the name given is invalid.

Parameters:
column The column name to get the ID of
Returns:
The ID number of the column provided

Implements SQLresult.

Definition at line 201 of file m_mysql.cpp.

References colnames.

virtual int MySQLresult::Cols  )  [inline, virtual]
 

Return the number of columns in the result.

If you performed an UPDATE or INSERT which does not return a dataset, this value will be 0.

Returns:
Number of columns in the result set.

Implements SQLresult.

Definition at line 183 of file m_mysql.cpp.

References colnames.

Referenced by GetRowMap(), GetRowMapPtr(), and GetValue().

virtual void MySQLresult::Free SQLfieldList fl  )  [inline, virtual]
 

Overloaded function for freeing the lists and maps returned by GetRowPtr or GetRowMapPtr.

Parameters:
fl The SQLfieldList to free

Implements SQLresult.

Definition at line 285 of file m_mysql.cpp.

virtual void MySQLresult::Free SQLfieldMap fm  )  [inline, virtual]
 

Overloaded function for freeing the lists and maps returned by GetRowPtr or GetRowMapPtr.

Parameters:
fm The SQLfieldMap to free

Implements SQLresult.

Definition at line 280 of file m_mysql.cpp.

virtual SQLfieldList& MySQLresult::GetRow  )  [inline, virtual]
 

Return a list of values in a row, this should increment an internal counter so you can repeatedly call it until it returns an empty vector.

This returns a reference to an internal object, the same object is used for all calls to this function and therefore the return value is only valid until you call this function again. It is also invalid if the SQLresult object is destroyed. The internal cursor (row counter) is incremented by one.

Returns:
A reference to the current row's SQLfieldList

Implements SQLresult.

Definition at line 225 of file m_mysql.cpp.

References currentrow, emptyfieldlist, fieldlists, and rows.

virtual SQLfieldMap& MySQLresult::GetRowMap  )  [inline, virtual]
 

As above, but return a map indexed by key name.

The internal cursor (row counter) is incremented by one.

Returns:
A reference to the current row's SQLfieldMap

Implements SQLresult.

Definition at line 233 of file m_mysql.cpp.

References colnames, Cols(), currentrow, fieldmap2, GetValue(), and rows.

virtual SQLfieldMap* MySQLresult::GetRowMapPtr  )  [inline, virtual]
 

As above, but return a map indexed by key name The internal cursor (row counter) is incremented by one.

Returns:
A newly-allocated SQLfieldMap

Implements SQLresult.

Definition at line 264 of file m_mysql.cpp.

References colnames, Cols(), currentrow, fieldmap, GetValue(), and rows.

virtual SQLfieldList* MySQLresult::GetRowPtr  )  [inline, virtual]
 

Like GetRow(), but returns a pointer to a dynamically allocated object which must be explicitly freed.

For portability reasons this must be freed with SQLresult::Free() The internal cursor (row counter) is incremented by one.

Returns:
A newly-allocated SQLfieldList

Implements SQLresult.

Definition at line 249 of file m_mysql.cpp.

References currentrow, fieldlists, Rows(), and rows.

virtual SQLfield MySQLresult::GetValue int  row,
int  column
[inline, virtual]
 

Get a string value in a given row and column This does not effect the internal cursor.

Returns:
The value stored at [row,column] in the table

Implements SQLresult.

Definition at line 212 of file m_mysql.cpp.

References Cols(), fieldlists, and rows.

Referenced by GetRowMap(), and GetRowMapPtr().

virtual int MySQLresult::Rows  )  [inline, virtual]
 

Return the number of rows in the result Note that if you have perfomed an INSERT or UPDATE query or other query which will not return rows, this will return the number of affected rows, and SQLresult::Cols() will contain 0.

In this case you SHOULD NEVER access any of the result set rows, as there arent any!

Returns:
Number of rows in the result set.

Implements SQLresult.

Definition at line 178 of file m_mysql.cpp.

References rows.

Referenced by GetRowPtr().


Member Data Documentation

std::vector<std::string> MySQLresult::colnames [private]
 

Definition at line 114 of file m_mysql.cpp.

Referenced by ColName(), ColNum(), Cols(), GetRowMap(), GetRowMapPtr(), and MySQLresult().

int MySQLresult::currentrow [private]
 

Definition at line 113 of file m_mysql.cpp.

Referenced by GetRow(), GetRowMap(), GetRowMapPtr(), and GetRowPtr().

SQLfieldList MySQLresult::emptyfieldlist [private]
 

Definition at line 118 of file m_mysql.cpp.

Referenced by GetRow().

std::vector<SQLfieldList> MySQLresult::fieldlists [private]
 

Definition at line 115 of file m_mysql.cpp.

Referenced by GetRow(), GetRowPtr(), GetValue(), and MySQLresult().

SQLfieldMap* MySQLresult::fieldmap [private]
 

Definition at line 116 of file m_mysql.cpp.

Referenced by GetRowMapPtr().

SQLfieldMap MySQLresult::fieldmap2 [private]
 

Definition at line 117 of file m_mysql.cpp.

Referenced by GetRowMap().

int MySQLresult::rows [private]
 

Definition at line 119 of file m_mysql.cpp.

Referenced by GetRow(), GetRowMap(), GetRowMapPtr(), GetRowPtr(), GetValue(), MySQLresult(), and Rows().


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