Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

pqxxobject::table< Row > Class Template Reference

Database table convenience wrapper. More...

#include <table.h>

List of all members.

Public Types

typedef Row row_type
 The type of the row the table contains.

typedef Row::row_ptr row_ptr
 Row object pointer.

typedef std::list< Row > row_list
 List of rows.

typedef std::auto_ptr< row_listrow_list_ptr
 List of rows pointer.


Public Member Functions

virtual ~table ()
 The destructor.

virtual void insert (row_type &row)
 Add a new row.

virtual void update (row_type &row)
 Update the details of an existing row.

virtual void erase (row_type &row)
 Erase (remove) a row.

virtual void refresh (row_type &row)
 Refresh a row (synchronise with current database state).


Protected Member Functions

 table (pqxxobject::transaction &tran)
 The constructor.

virtual row_ptr find_one (const std::string &query)
 Find a single row from the database.

virtual row_list_ptr find_many (const std::string &query)
 Find multiple rows from the database.


Protected Attributes

pqxxobject::transactionm_transaction


Detailed Description

template<typename Row>
class pqxxobject::table< Row >

Database table convenience wrapper.

This class provides methods to simplify table access for classes which represent database tables. Methods are provided to find single and multiple rows and to insert, update and delete rows from the table.

Definition at line 57 of file table.h.


Member Typedef Documentation

template<typename Row>
typedef std::list<Row> pqxxobject::table< Row >::row_list
 

List of rows.

Definition at line 65 of file table.h.

Referenced by pqxxobject::table< Row >::find_many().

template<typename Row>
typedef std::auto_ptr<row_list> pqxxobject::table< Row >::row_list_ptr
 

List of rows pointer.

Definition at line 67 of file table.h.

Referenced by pqxxobject::table< Row >::find_many().

template<typename Row>
typedef Row::row_ptr pqxxobject::table< Row >::row_ptr
 

Row object pointer.

Definition at line 63 of file table.h.

Referenced by pqxxobject::table< Row >::find_many(), and pqxxobject::table< Row >::find_one().

template<typename Row>
typedef Row pqxxobject::table< Row >::row_type
 

The type of the row the table contains.

Definition at line 61 of file table.h.

Referenced by pqxxobject::table< Row >::erase(), pqxxobject::table< Row >::insert(), pqxxobject::table< Row >::refresh(), and pqxxobject::table< Row >::update().


Constructor & Destructor Documentation

template<typename Row>
pqxxobject::table< Row >::table pqxxobject::transaction tran  )  [inline, explicit, protected]
 

The constructor.

Parameters:
tran a pointer to a PostgreSQL transaction object. This must have been previously created from connection. If set to NULL, table will run in auto-commit mode, and will create a new transaction for each database operation.

Definition at line 79 of file table.h.

References pqxxobject::table< Row >::m_transaction.

template<typename Row>
virtual pqxxobject::table< Row >::~table  )  [inline, virtual]
 

The destructor.

Definition at line 85 of file table.h.


Member Function Documentation

template<typename Row>
virtual void pqxxobject::table< Row >::erase row_type row  )  [inline, virtual]
 

Erase (remove) a row.

Parameters:
row the row to erase.

Definition at line 116 of file table.h.

References pqxxobject::table< Row >::m_transaction, and pqxxobject::table< Row >::row_type.

template<typename Row>
virtual row_list_ptr pqxxobject::table< Row >::find_many const std::string &  query  )  [inline, protected, virtual]
 

Find multiple rows from the database.

Parameters:
query the SQL query to run.
Returns:
a pointer to a vector of rows.

Definition at line 176 of file table.h.

References pqxxobject::transaction::abort(), pqxxobject::transaction::begin(), pqxxobject::transaction::commit(), pqxxobject::transaction::exec(), pqxxobject::table< Row >::m_transaction, pqxxobject::table< Row >::row_list, pqxxobject::table< Row >::row_list_ptr, and pqxxobject::table< Row >::row_ptr.

template<typename Row>
virtual row_ptr pqxxobject::table< Row >::find_one const std::string &  query  )  [inline, protected, virtual]
 

Find a single row from the database.

Parameters:
query the SQL query to run.
Returns:
a pointer to row, or NULL if no member was found.

Definition at line 140 of file table.h.

References pqxxobject::transaction::abort(), pqxxobject::transaction::begin(), pqxxobject::transaction::commit(), pqxxobject::transaction::exec(), pqxxobject::table< Row >::m_transaction, and pqxxobject::table< Row >::row_ptr.

template<typename Row>
virtual void pqxxobject::table< Row >::insert row_type row  )  [inline, virtual]
 

Add a new row.

Parameters:
row the row to add.

Definition at line 94 of file table.h.

References pqxxobject::table< Row >::m_transaction, and pqxxobject::table< Row >::row_type.

template<typename Row>
virtual void pqxxobject::table< Row >::refresh row_type row  )  [inline, virtual]
 

Refresh a row (synchronise with current database state).

Parameters:
row the row to refresh.

Definition at line 127 of file table.h.

References pqxxobject::table< Row >::m_transaction, and pqxxobject::table< Row >::row_type.

template<typename Row>
virtual void pqxxobject::table< Row >::update row_type row  )  [inline, virtual]
 

Update the details of an existing row.

Parameters:
row the row to update.

Definition at line 105 of file table.h.

References pqxxobject::table< Row >::m_transaction, and pqxxobject::table< Row >::row_type.


Member Data Documentation

template<typename Row>
pqxxobject::transaction& pqxxobject::table< Row >::m_transaction [protected]
 

Definition at line 206 of file table.h.

Referenced by pqxxobject::table< Row >::erase(), pqxxobject::table< Row >::find_many(), pqxxobject::table< Row >::find_one(), pqxxobject::table< Row >::insert(), pqxxobject::table< Row >::refresh(), pqxxobject::table< Row >::table(), and pqxxobject::table< Row >::update().


The documentation for this class was generated from the following file:
Generated on Thu Apr 1 12:53:11 2004 for pqxx-object API Reference by doxygen 1.3.5