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

SQLresult Class Reference

SQLresult is a reply to a previous query. More...

#include <m_sqlv2.h>

Inheritance diagram for SQLresult:

Inheritance graph
[legend]
Collaboration diagram for SQLresult:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 SQLresult (Module *s, Module *d, unsigned long i)
 Used by the SQL API to instantiate an SQLrequest.
virtual int Rows ()=0
 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 ()=0
 Return the number of columns in the result.
virtual std::string ColName (int column)=0
 Get a string name of the column by an index number.
virtual int ColNum (const std::string &column)=0
 Get an index number for a column from a string name.
virtual SQLfield GetValue (int row, int column)=0
 Get a string value in a given row and column This does not effect the internal cursor.
virtual SQLfieldListGetRow ()=0
 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 ()=0
 As above, but return a map indexed by key name.
virtual SQLfieldListGetRowPtr ()=0
 Like GetRow(), but returns a pointer to a dynamically allocated object which must be explicitly freed.
virtual SQLfieldMapGetRowMapPtr ()=0
 As above, but return a map indexed by key name The internal cursor (row counter) is incremented by one.
virtual void Free (SQLfieldMap *fm)=0
 Overloaded function for freeing the lists and maps returned by GetRowPtr or GetRowMapPtr.
virtual void Free (SQLfieldList *fl)=0
 Overloaded function for freeing the lists and maps returned by GetRowPtr or GetRowMapPtr.

Public Attributes

std::string query
 The original query string passed initially to the SQL API.
std::string dbid
 The database ID the query was executed on.
SQLerror error
 The error (if any) which occured.
unsigned long id
 This will match query ID you were given when sending the request at an earlier time.

Detailed Description

SQLresult is a reply to a previous query.

If you send a query to the SQL api, the response will arrive at your OnRequest method of your module at some later time, depending on the congestion of the SQL server and complexity of the query. The ID of this result will match the ID assigned to your original request. SQLresult contains its own internal cursor (row counter) which is incremented with each method call which retrieves a single row.

Definition at line 301 of file m_sqlv2.h.


Constructor & Destructor Documentation

SQLresult::SQLresult Module s,
Module d,
unsigned long  i
[inline]
 

Used by the SQL API to instantiate an SQLrequest.

Definition at line 324 of file m_sqlv2.h.


Member Function Documentation

virtual std::string SQLresult::ColName int  column  )  [pure 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

Implemented in MsSQLResult, MySQLresult, PgSQLresult, and SQLite3Result.

Referenced by ModuleTestClient::OnRequest().

virtual int SQLresult::ColNum const std::string column  )  [pure 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

Implemented in MsSQLResult, MySQLresult, PgSQLresult, and SQLite3Result.

virtual int SQLresult::Cols  )  [pure 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.

Implemented in MsSQLResult, MySQLresult, PgSQLresult, and SQLite3Result.

Referenced by ModuleTestClient::OnRequest().

virtual void SQLresult::Free SQLfieldList fl  )  [pure virtual]
 

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

Parameters:
fl The SQLfieldList to free

Implemented in MsSQLResult, MySQLresult, PgSQLresult, and SQLite3Result.

virtual void SQLresult::Free SQLfieldMap fm  )  [pure virtual]
 

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

Parameters:
fm The SQLfieldMap to free

Implemented in MsSQLResult, MySQLresult, PgSQLresult, and SQLite3Result.

virtual SQLfieldList& SQLresult::GetRow  )  [pure 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

Implemented in MsSQLResult, MySQLresult, PgSQLresult, and SQLite3Result.

virtual SQLfieldMap& SQLresult::GetRowMap  )  [pure 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

Implemented in MsSQLResult, MySQLresult, PgSQLresult, and SQLite3Result.

Referenced by ModuleSQLOper::OnRequest().

virtual SQLfieldMap* SQLresult::GetRowMapPtr  )  [pure 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

Implemented in MsSQLResult, MySQLresult, PgSQLresult, and SQLite3Result.

virtual SQLfieldList* SQLresult::GetRowPtr  )  [pure 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

Implemented in MsSQLResult, MySQLresult, PgSQLresult, and SQLite3Result.

virtual SQLfield SQLresult::GetValue int  row,
int  column
[pure 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

Implemented in MsSQLResult, MySQLresult, PgSQLresult, and SQLite3Result.

Referenced by QueryInfo::Go(), and ModuleTestClient::OnRequest().

virtual int SQLresult::Rows  )  [pure 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.

Implemented in MsSQLResult, MySQLresult, PgSQLresult, and SQLite3Result.

Referenced by QueryInfo::Go(), ModuleTestClient::OnRequest(), ModuleSQLOper::OnRequest(), and ModuleSQLAuth::OnRequest().


Member Data Documentation

std::string SQLresult::dbid
 

The database ID the query was executed on.

Definition at line 309 of file m_sqlv2.h.

Referenced by SQLConnection::DoLeadingQuery(), and SQLConn::Query().

SQLerror SQLresult::error
 

The error (if any) which occured.

If an error occured the value of error.id will be any other value than SQL_NO_ERROR.

Definition at line 315 of file m_sqlv2.h.

Referenced by SQLConn::DoConnectedPoll(), MySQLresult::MySQLresult(), ModuleTestClient::OnRequest(), ModuleSQLOper::OnRequest(), and ModuleSQLAuth::OnRequest().

unsigned long SQLresult::id
 

This will match query ID you were given when sending the request at an earlier time.

Reimplemented from Request.

Definition at line 320 of file m_sqlv2.h.

Referenced by ModuleSQLOper::OnRequest(), ModuleSQLLog::OnRequest(), and ModuleSQLAuth::OnRequest().

std::string SQLresult::query
 

The original query string passed initially to the SQL API.

Definition at line 306 of file m_sqlv2.h.

Referenced by SQLConn::DoConnectedPoll(), SQLConnection::DoLeadingQuery(), and SQLConn::Query().


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