#include <result.h>
Public Member Functions | |
UseQueryResult () | |
Default constructor. | |
UseQueryResult (MYSQL_RES *result, DBDriver *dbd, bool te=true) | |
Create the object, fully initialized. | |
UseQueryResult (const UseQueryResult &other) | |
Create a copy of another UseQueryResult object. | |
~UseQueryResult () | |
Destroy object. | |
UseQueryResult & | operator= (const UseQueryResult &rhs) |
Copy another UseQueryResult object's data into this object. | |
const Field & | fetch_field () const |
Returns the next field in this result set. | |
const Field & | fetch_field (Fields::size_type i) const |
Returns the given field in this result set. | |
const unsigned long * | fetch_lengths () const |
Returns the lengths of the fields in the current row of the result set. | |
Row | fetch_row () const |
Returns the next row in a "use" query's result set. | |
MYSQL_ROW | fetch_raw_row () const |
Wraps mysql_fetch_row() in MySQL C API. | |
void | field_seek (Fields::size_type field) const |
Jumps to the given field within the result set. | |
operator MYSQL_RES * () const | |
Return the pointer to the underlying MySQL C API result set object. |
See the user manual for the reason you might want to use this even though its interface is less friendly than StoreQueryResult's.
Row mysqlpp::UseQueryResult::fetch_row | ( | ) | const |
Returns the next row in a "use" query's result set.
This is a thick wrapper around DBDriver::fetch_row(). It does a lot of error checking before returning the Row object containing the row data.
References mysqlpp::ResultBase::driver_, fetch_lengths(), mysqlpp::DBDriver::fetch_row(), mysqlpp::RefCountedPointer< T, Destroyer >::raw(), and mysqlpp::OptionalExceptions::throw_exceptions().
Referenced by mysqlpp::Query::for_each(), and mysqlpp::Query::store_if().
void mysqlpp::UseQueryResult::field_seek | ( | Fields::size_type | field | ) | const [inline] |
Jumps to the given field within the result set.
Calling this allows you to reset the default field index used by fetch_field().
mysqlpp::UseQueryResult::operator MYSQL_RES * | ( | ) | const [inline] |
Return the pointer to the underlying MySQL C API result set object.
While this has obvious inherent value for those times you need to dig beneath the MySQL++ interface, it has subtler value. It effectively stands in for operator bool(), operator !(), operator ==(), and operator !=(), because the C++ compiler can implement all of these with a MYSQL_RES*.
Of these uses, the most valuable is using the UseQueryResult object in bool context to determine if the query that created
Query q("...."); if (UseQueryResult res = q.use()) { // Can use 'res', query succeeded } else { // Query failed, call Query::error() or ::errnum() for why }