MySQL++  3.3.0
Public Member Functions | List of all members
mysqlpp::UseQueryResult Class Reference

StoreQueryResult set type for "use" queries. More...

#include <result.h>

Inheritance diagram for mysqlpp::UseQueryResult:
Inheritance graph
[legend]
Collaboration diagram for mysqlpp::UseQueryResult:
Collaboration graph
[legend]

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.
 
UseQueryResultoperator= (const UseQueryResult &rhs)
 Copy another UseQueryResult object's data into this object.
 
const Fieldfetch_field () const
 Returns the next field in this result set.
 
const Fieldfetch_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. More...
 
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. More...
 
 operator MYSQL_RES * () const
 Return the pointer to the underlying MySQL C API result set object. More...
 
- Public Member Functions inherited from mysqlpp::ResultBase
virtual ~ResultBase ()
 Destroy object.
 
const Fieldfetch_field () const
 Returns the next field in this result set.
 
const Fieldfetch_field (Fields::size_type i) const
 Returns the given field in this result set.
 
const Fieldfield (unsigned int i) const
 Get the underlying Field structure given its index.
 
const Fieldsfields () const
 Get the underlying Fields structure.
 
const std::string & field_name (int i) const
 Get the name of the field at the given index.
 
const RefCountedPointer< FieldNames > & field_names () const
 Get the names of the fields within this result set.
 
int field_num (const std::string &) const
 Get the index of the named field. More...
 
const FieldTypes::value_type & field_type (int i) const
 Get the type of a particular field within this result set.
 
const RefCountedPointer< FieldTypes > & field_types () const
 Get a list of the types of the fields within this result set.
 
size_t num_fields () const
 Returns the number of fields in this result set.
 
const char * table () const
 Return the name of the table the result set comes from.
 
- Public Member Functions inherited from mysqlpp::OptionalExceptions
 OptionalExceptions (bool e=true)
 Default constructor. More...
 
virtual ~OptionalExceptions ()
 Destroy object.
 
void enable_exceptions () const
 Enable exceptions from the object.
 
void disable_exceptions () const
 Disable exceptions from the object.
 
bool throw_exceptions () const
 Returns true if exceptions are enabled.
 

Additional Inherited Members

- Protected Member Functions inherited from mysqlpp::ResultBase
 ResultBase ()
 Create empty object.
 
 ResultBase (MYSQL_RES *result, DBDriver *dbd, bool te=true)
 Create the object, fully initialized.
 
 ResultBase (const ResultBase &other)
 Create object as a copy of another ResultBase.
 
ResultBasecopy (const ResultBase &other)
 Copy another ResultBase object's contents into this one.
 
- Protected Member Functions inherited from mysqlpp::OptionalExceptions
void set_exceptions (bool e) const
 Sets the exception state to a particular value. More...
 
- Protected Attributes inherited from mysqlpp::ResultBase
DBDriverdriver_
 Access to DB driver; fully initted if nonzero.
 
Fields fields_
 list of fields in result
 
RefCountedPointer< FieldNamesnames_
 list of field names in result
 
RefCountedPointer< FieldTypestypes_
 list of field types in result
 
Fields::size_type current_field_
 Default field index used by fetch_field() More...
 

Detailed Description

StoreQueryResult set type for "use" queries.

See the user manual for the reason you might want to use this even though its interface is less friendly than StoreQueryResult's.

Member Function Documentation

◆ fetch_row()

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.

See also
fetch_raw_row()

References mysqlpp::ResultBase::driver_, mysqlpp::DBDriver::errnum(), mysqlpp::DBDriver::error(), 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().

◆ field_seek()

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().

◆ operator MYSQL_RES *()

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
}
UseQueryResult()
Default constructor.
Definition: result.h:302

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