00001
00002
00003
00004
00005
00006
00007 #ifndef OPENDBPG_H
00008 #define OPENDBPG_H 1
00009
00010 extern "C"
00011 {
00012 #include <libpq-fe.h>
00013 }
00014 #include "openDB.h"
00015
00016 class postgresDB: public openDB
00017 {
00018
00019 protected:
00020 PGconn *conn;
00021 bool isTransactioning;
00022 virtual openCMD * createCommand();
00023 virtual openRS * createRecordset();
00024
00025 public:
00026
00027 postgresDB( string strConnection );
00028 virtual ~postgresDB();
00029 PGconn * getConnection( void );
00030 virtual dbProvider getProvider( void );
00031 inline bool transactioning( void ){ return isTransactioning; }
00032 inline void transactioning( bool in ){ isTransactioning=in; }
00033
00034
00035 };
00036
00037
00038
00039
00040
00041 class postgresCMD: public openCMD
00042 {
00043
00044 protected:
00045 PGconn * conn;
00046 postgresDB &db;
00047 Oid oid;
00048 int iRows;
00049 PGresult *res;
00050 bool checkRes( ExecStatusType desired );
00051
00052
00053 public:
00054
00055 postgresCMD( openDB & idb );
00056
00057 virtual ~postgresCMD();
00058
00059
00060 virtual bool execute( string );
00061 virtual int resultId( void ){ return static_cast<int>(oid); };
00062
00063 virtual bool beginTransaction();
00064 virtual bool commit();
00065 virtual bool rollback();
00066
00067 };
00068
00069
00070
00071
00072
00073 class postgresRS: public openRS
00074 {
00075 protected:
00076
00077 PGconn *conn;
00078 postgresDB &db;
00079 static int iCursors;
00080 string strCursorName;
00081 PGresult *res;
00082 bool checkRes( ExecStatusType desired );
00083 bool beginTransaction();
00084 bool commit();
00085 public:
00086
00087 postgresRS( openDB & idb );
00088
00089 virtual ~ postgresRS();
00090
00091 virtual bool open( string sql );
00092 virtual bool close( void );
00093 virtual bool next( int rows = 1 );
00094
00095 virtual bool previous( int rows = 1 );
00096
00097 };
00098
00099 #endif