libtabula::UseQueryResult Class Reference

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

#include <result.h>

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

List of all members.

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

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

Row libtabula::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 libtabula::ResultBase::driver_, fetch_lengths(), libtabula::DBDriver::fetch_row(), libtabula::RefCountedPointer< T, Destroyer >::raw(), and libtabula::OptionalExceptions::throw_exceptions().

Referenced by libtabula::Query::for_each(), and libtabula::Query::store_if().

void libtabula::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().

libtabula::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 Libtabula 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
   }

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

Generated on 26 May 2014 for Libtabula by  doxygen 1.6.1