diff --git a/src/qgspgutil.cpp b/src/qgspgutil.cpp index f51da16a435..c74cc87a4a0 100644 --- a/src/qgspgutil.cpp +++ b/src/qgspgutil.cpp @@ -40,6 +40,14 @@ bool QgsPgUtil::isReserved(QString word) QStringList::iterator it = mReservedWords.find(word.upper()); return (it != mReservedWords.end()); } +void QgsPgUtil::setConnection(PGconn *con) +{ + mPgConnection = con; +} +PGconn *QgsPgUtil::connection() +{ + return mPgConnection; +} void QgsPgUtil::initReservedWords() { // create the reserved word list by loading diff --git a/src/qgspgutil.h b/src/qgspgutil.h index d5c920420f1..341bc01c501 100644 --- a/src/qgspgutil.h +++ b/src/qgspgutil.h @@ -17,6 +17,11 @@ #define QGSPGUTIL_H #include #include +extern "C" +{ + #include +} + /*! * \class QgsPgUtil * \brief Class containing utility functions for working with PostgreSQL @@ -34,6 +39,16 @@ class QgsPgUtil * @return True if word is a PG reserved word */ bool isReserved(QString word); + /*! + * Set the connection to be used in database operations + * @param con Pointer to an active PostgreSQL connection + */ + void setConnection(PGconn *con); + /*! + * Get the connection currently in use for database operations + * @return Pointer to the PostgreSQL connection object + */ + PGconn *connection(); protected: //! Protected constructor QgsPgUtil(); @@ -46,5 +61,7 @@ class QgsPgUtil static QgsPgUtil* mInstance; //! Reserved word list QStringList mReservedWords; + //! PostgreSQL connection + PGconn *mPgConnection; }; #endif // QGSPGUTIL_H