kexi
pqxxconnection.h
00001 /* This file is part of the KDE project 00002 Copyright (C) 2003 Adam Pigg <adam@piggz.co.uk> 00003 00004 This program is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This program is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this program; see the file COPYING. If not, write to 00016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 * Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #ifndef PQXXCONNECTION_H 00021 #define PQXXCONNECTION_H 00022 00023 #include <qstringlist.h> 00024 00025 #include <kexidb/connection.h> 00026 #include "pqxxcursor.h" 00027 00028 00029 00030 00031 namespace KexiDB 00032 { 00033 00034 class pqxxSqlConnectionInternal; 00035 00037 class pqxxTransactionData : public TransactionData 00038 { 00039 public: 00040 pqxxTransactionData(Connection *conn, bool nontransaction); 00041 ~pqxxTransactionData(); 00042 pqxx::transaction_base *data; 00043 }; 00044 00048 class pqxxSqlConnection : public Connection 00049 { 00050 Q_OBJECT 00051 00052 public: 00053 virtual ~pqxxSqlConnection(); 00054 00055 virtual Cursor* prepareQuery( const QString& statement = QString::null, uint cursor_options = 0 ); 00056 virtual Cursor* prepareQuery( QuerySchema& query, uint cursor_options = 0 ); 00057 virtual PreparedStatement::Ptr prepareStatement(PreparedStatement::StatementType type, 00058 FieldList& fields); 00059 protected: 00060 00061 pqxxSqlConnection( Driver *driver, ConnectionData &conn_data ); 00062 00063 virtual bool drv_isDatabaseUsed() const; 00064 virtual bool drv_connect(KexiDB::ServerVersionInfo& version); 00065 virtual bool drv_disconnect(); 00066 virtual bool drv_getDatabasesList( QStringList &list ); 00067 virtual bool drv_createDatabase( const QString &dbName = QString::null ); 00068 virtual bool drv_useDatabase( const QString &dbName = QString::null, bool *cancelled = 0, 00069 MessageHandler* msgHandler = 0 ); 00070 virtual bool drv_closeDatabase(); 00071 virtual bool drv_dropDatabase( const QString &dbName = QString::null ); 00072 virtual bool drv_executeSQL( const QString& statement ); 00073 virtual Q_ULLONG drv_lastInsertRowID(); 00074 00075 //TODO: move this somewhere to low level class (MIGRATION?) 00076 virtual bool drv_getTablesList( QStringList &list ); 00077 //TODO: move this somewhere to low level class (MIGRATION?) 00078 virtual bool drv_containsTable( const QString &tableName ); 00079 00080 virtual TransactionData* drv_beginTransaction(); 00081 virtual bool drv_commitTransaction(TransactionData *); 00082 virtual bool drv_rollbackTransaction(TransactionData *); 00083 00084 //Error reporting 00085 virtual int serverResult(); 00086 virtual QString serverResultName(); 00087 virtual void drv_clearServerResult(); 00088 virtual QString serverErrorMsg(); 00089 00090 pqxxSqlConnectionInternal *d; 00091 private: 00092 QString escapeName(const QString &tn) const; 00093 // pqxx::transaction_base* m_trans; 00095 pqxxTransactionData *m_trans; 00096 00097 00098 00099 friend class pqxxSqlDriver; 00100 friend class pqxxSqlCursor; 00101 friend class pqxxTransactionData; 00102 }; 00103 } 00104 #endif