#include <ResultSet.h>
A ResultSet is like a table which holds the query result rows, in order to read such information you might have done something like:
xvr2::SQL::Connection *conn; . //Connect to a database successfully . //You will always obtain a ResultSet from query xvr2::SQL::ResultSet *result = conn->query("SELECT * FROM table"); //Retrieve each row in the set until fetchRow returns 0 while(result->fetchRow()){ //Read a colum from the row std::cout << result->get(0).toString(); . //Do whatever else you need with the rows in your set. . } delete result; //Release ResultSet resources
Definition at line 46 of file ResultSet.h.
Public Member Functions | |
ResultSet (Driver *drv, void *__rhandle, bool __status) | |
ResultSet (Driver *drv, void *__rhandle, bool __status, UInt64 afrows) | |
~ResultSet () | |
bool | status () |
Will hold the status of the previous query, if it was a query or not. | |
const int | numRows () |
Returns the number of retrieved rows in the ResultSet. | |
const int | numCols () |
Returns the number of retrieved columns in the ResultSet. | |
const String & | getColName (const int index) |
Returns the name of a column. | |
const Field * | getRow () |
This will return the current retrieved row as an array of Field elements. | |
const Field & | get (const int index) |
This will return the value of the given column: index in the currently retrieved row. | |
const Field & | get (const char *colname) |
This will return the value of the given column name: colname in the currently retrieved row. | |
const Field & | get (const String &colname) |
This will return the value of the given column name: colname in the currently retrieved row. | |
const Field * | fetchRow () |
Retrieves a row from an SQL result set. | |
const Field * | fetchNextRow () |
Use this method to move to next row to be read from the result stream. | |
const UInt64 | affectedRows () |
In the case you ran an update, delete or another query which does not return a ResultSet but alters the content of a tables, this method will tell you how many rows got affected as a result of the operation. | |
const char * | errorMessage () |
Returns the error message as returned by the RDBMS after this query was sent. | |
virtual const char * | getClassName () |
Returns the name of the current class. | |
virtual std::string | toString () |
Static Public Member Functions | |
static void | debugmsg (Object *obj, const char *msg, int linenumber=__LINE__, const char *srcfile=__FILE__) |
Will print a debug message to the screen. | |
static void | debugmsgln (Object *obj, const char *msg, int linenumber=__LINE__, const char *srcfile=__FILE__) |
Protected Attributes | |
bool | _status |
void * | r_handle |
A generic handle to the driver's specific resultset object. | |
Driver * | driver |
Points to the SQL driver in use. | |
Field * | row |
Holds the currect row in the stream. | |
int | ncols |
UInt64 | afrows |
bool | is_a_select |
int | ridx |
std::string | __cls_name |
Friends | |
std::ostream & | operator<< (std::ostream &stream, const Object &s) |
xvr2::SQL::ResultSet::ResultSet | ( | Driver * | drv, | |
void * | __rhandle, | |||
bool | __status | |||
) |
xvr2::SQL::ResultSet::~ResultSet | ( | ) |
bool xvr2::SQL::ResultSet::status | ( | ) |
Will hold the status of the previous query, if it was a query or not.
const int xvr2::SQL::ResultSet::numRows | ( | ) |
Returns the number of retrieved rows in the ResultSet.
const int xvr2::SQL::ResultSet::numCols | ( | ) |
Returns the number of retrieved columns in the ResultSet.
const String& xvr2::SQL::ResultSet::getColName | ( | const int | index | ) |
Returns the name of a column.
const Field* xvr2::SQL::ResultSet::getRow | ( | ) |
This will return the current retrieved row as an array of Field elements.
const Field& xvr2::SQL::ResultSet::get | ( | const int | index | ) |
This will return the value of the given column: index in the currently retrieved row.
const Field& xvr2::SQL::ResultSet::get | ( | const char * | colname | ) |
This will return the value of the given column name: colname in the currently retrieved row.
This will return the value of the given column name: colname in the currently retrieved row.
const Field* xvr2::SQL::ResultSet::fetchRow | ( | ) |
Retrieves a row from an SQL result set.
After you get a ResultSet as a result from a Connection::query call you must call this method so you can start reading the result set iteratively until you reach the last row in the set.
const Field* xvr2::SQL::ResultSet::fetchNextRow | ( | ) |
Use this method to move to next row to be read from the result stream.
This method will also return an array of Field elements representing the cells of the current row.
In case you reached the last row this method will return NULL instead of the Field array.
const UInt64 xvr2::SQL::ResultSet::affectedRows | ( | ) |
In the case you ran an update, delete or another query which does not return a ResultSet but alters the content of a tables, this method will tell you how many rows got affected as a result of the operation.
const char* xvr2::SQL::ResultSet::errorMessage | ( | ) |
Returns the error message as returned by the RDBMS after this query was sent.
virtual const char* xvr2::Object::getClassName | ( | ) | [virtual, inherited] |
Returns the name of the current class.
static void xvr2::Object::debugmsg | ( | Object * | obj, | |
const char * | msg, | |||
int | linenumber = __LINE__ , |
|||
const char * | srcfile = __FILE__ | |||
) | [static, inherited] |
Will print a debug message to the screen.
static void xvr2::Object::debugmsgln | ( | Object * | obj, | |
const char * | msg, | |||
int | linenumber = __LINE__ , |
|||
const char * | srcfile = __FILE__ | |||
) | [static, inherited] |
virtual std::string xvr2::Object::toString | ( | ) | [virtual, inherited] |
std::ostream& operator<< | ( | std::ostream & | stream, | |
const Object & | s | |||
) | [friend, inherited] |
bool xvr2::SQL::ResultSet::_status [protected] |
Definition at line 49 of file ResultSet.h.
void* xvr2::SQL::ResultSet::r_handle [protected] |
A generic handle to the driver's specific resultset object.
Definition at line 51 of file ResultSet.h.
Driver* xvr2::SQL::ResultSet::driver [protected] |
Field* xvr2::SQL::ResultSet::row [protected] |
int xvr2::SQL::ResultSet::ncols [protected] |
Definition at line 56 of file ResultSet.h.
UInt64 xvr2::SQL::ResultSet::afrows [protected] |
Definition at line 57 of file ResultSet.h.
bool xvr2::SQL::ResultSet::is_a_select [protected] |
Definition at line 58 of file ResultSet.h.
int xvr2::SQL::ResultSet::ridx [protected] |
Definition at line 59 of file ResultSet.h.
std::string xvr2::Object::__cls_name [protected, inherited] |