From 0b92dc3d2b2d33c14944514c7957efc308a1c330 Mon Sep 17 00:00:00 2001 From: om Date: Sat, 22 Jul 2006 16:30:03 +0000 Subject: 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 --- src/modules/extra/m_pgsql.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/modules/extra/m_pgsql.cpp') 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 #include #include #include @@ -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() -- cgit v1.3.1-10-gc9f91