Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class 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 std::auto_ptr< Row > row_ptr
typedef std::list< Row > row_list
typedef std::auto_ptr< row_listrow_list_ptr

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. A default method for modifying the database is also provided, but this should be overridden in all but the simplest classes.

Definition at line 41 of file table.h.


Member Typedef Documentation

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

Definition at line 47 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
 

Definition at line 48 of file table.h.

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

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

Definition at line 46 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 45 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(), and pqxxobject::table< Row >::update().


Constructor & Destructor Documentation

template<typename Row>
pqxxobject::table< Row >::table pqxxobject::transaction tran  )  [inline, 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 60 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 67 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 98 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 160 of file table.h.

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

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 122 of file table.h.

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

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 76 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 109 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 87 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 190 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 Sat Jan 17 20:58:43 2004 for pqxx-object API Reference by doxygen 1.3.4