diff options
author | om <om@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-07-22 16:30:03 +0000 |
---|---|---|
committer | om <om@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-07-22 16:30:03 +0000 |
commit | 0b92dc3d2b2d33c14944514c7957efc308a1c330 (patch) | |
tree | 93eef0d32cd22dccee2251b88e0fb583b6e294bb /src/modules/extra/m_pgsql.cpp | |
parent | 0f4fa12f1ef4158297710551ad5bfcfc82e8df48 (diff) |
Make m_pgsql return the number of affected rows for an UPDATE or INSERT query.
Make m_testclient do an INSERT and test this :p
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4517 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/extra/m_pgsql.cpp')
-rw-r--r-- | src/modules/extra/m_pgsql.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/modules/extra/m_pgsql.cpp b/src/modules/extra/m_pgsql.cpp index f9de9f516..7b452e7c6 100644 --- a/src/modules/extra/m_pgsql.cpp +++ b/src/modules/extra/m_pgsql.cpp @@ -15,6 +15,7 @@ * --------------------------------------------------- */ +#include <cstdlib> #include <sstream> #include <string> #include <deque> @@ -205,6 +206,8 @@ class PgSQLresult : public SQLresult { PGresult* res; int currentrow; + int rows; + int cols; SQLfieldList* fieldlist; SQLfieldMap* fieldmap; @@ -212,10 +215,10 @@ public: PgSQLresult(Module* self, Module* to, unsigned long id, PGresult* result) : SQLresult(self, to, id), res(result), currentrow(0), fieldlist(NULL), fieldmap(NULL) { - int rows = PQntuples(res); - int cols = PQnfields(res); + rows = PQntuples(res); + cols = PQnfields(res); - log(DEBUG, "Created new PgSQL result; %d rows, %d columns", rows, cols); + log(DEBUG, "Created new PgSQL result; %d rows, %d columns, %s affected", rows, cols, PQcmdTuples(res)); } ~PgSQLresult() @@ -225,7 +228,14 @@ public: virtual int Rows() { - return PQntuples(res); + if(!cols && !rows) + { + return atoi(PQcmdTuples(res)); + } + else + { + return rows; + } } virtual int Cols() |