#include <sqlresult.hpp>
Public Member Functions | |
| SqlResult () | |
| Constructor. | |
| ~SqlResult () | |
| Destructor. | |
| int | rows () const |
| Find out how many rows are in the result set. | |
| string | fetch () |
| Get the next data field in the result set. | |
| int | fetchInteger () |
| Get the next data field in the result set, converted to an int. | |
| long | fetchLong () |
| Get the next data field in the result set, converted to a long. | |
| float | fetchFloat () |
| Get the next data field in the result set, converted to a float. | |
| double | fetchDouble () |
| Get the next data field in the result set, converted to a double. | |
| const char * | fetchCstring () |
| Get the next data field in the result set, converted to a C style pointer based string constant. | |
| void | skip (int columns=1) |
| Skip the next data field in the result set. | |
| void | skipRow () |
| Skip the rest of the row. | |
| bool | empty () const |
| Find out if there are any results in the set. | |
| void | add (SqlRow *newRow) |
| add a row to the result set. | |
SqlDatabase *db = new MySqlContext( ... ); SqlQuery query( *db ); SqlResult result = query( "SELECT * FROM my_table;" ); while( !result.empty() ) { std::string myString = result.fetch(); int myInt = result.fetchInteger(); // do something with myText and myInt } delete db;
Definition at line 87 of file sqlresult.hpp.
| SqlResult::SqlResult | ( | ) |
| SqlResult::~SqlResult | ( | ) |
| int SqlResult::rows | ( | ) | const |
Find out how many rows are in the result set.
Definition at line 93 of file sqlresult.cpp.
| string SqlResult::fetch | ( | ) |
Get the next data field in the result set.
This member function will, in addition to returning the data, also delete it from the result set.
Definition at line 98 of file sqlresult.cpp.
References SqlRow::empty(), and SqlRow::fetch().
Referenced by fetchCstring(), fetchDouble(), fetchFloat(), fetchInteger(), fetchLong(), and skip().
| int SqlResult::fetchInteger | ( | ) |
Get the next data field in the result set, converted to an int.
Definition at line 117 of file sqlresult.cpp.
References fetch().
| long SqlResult::fetchLong | ( | ) |
Get the next data field in the result set, converted to a long.
Definition at line 122 of file sqlresult.cpp.
References fetch().
| float SqlResult::fetchFloat | ( | ) |
Get the next data field in the result set, converted to a float.
Definition at line 127 of file sqlresult.cpp.
References fetch().
| double SqlResult::fetchDouble | ( | ) |
Get the next data field in the result set, converted to a double.
Definition at line 132 of file sqlresult.cpp.
References fetch().
| const char * SqlResult::fetchCstring | ( | ) |
Get the next data field in the result set, converted to a C style pointer based string constant.
Definition at line 137 of file sqlresult.cpp.
References fetch().
| void SqlResult::skip | ( | int | columns = 1 |
) |
Skip the next data field in the result set.
| columns | The number of fields/columns to skip. If not specified (or if negative) a default of 1 is used. |
Definition at line 142 of file sqlresult.cpp.
References fetch().
| void SqlResult::skipRow | ( | ) |
Skip the rest of the row.
The next fetch you do will return the first field in the next row.
Definition at line 151 of file sqlresult.cpp.
| bool SqlResult::empty | ( | ) | const |
Find out if there are any results in the set.
This function is typically used as an expression in a loop.
Definition at line 161 of file sqlresult.cpp.
| void SqlResult::add | ( | SqlRow * | newRow | ) |
add a row to the result set.
Note that this is used by the inherited SqlDatabase classes, so there should be no reason for you use this function directly.
| newRow | The SqlRow to be added. |
Definition at line 88 of file sqlresult.cpp.
1.5.0