Module: sip-router
Branch: master
Commit: 588d1ffbb7b6e5074e3dbb6950b2149544ea1521
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=588d1ff…
Author: Alex Hermann <alex(a)speakup.nl>
Committer: Alex Hermann <alex(a)speakup.nl>
Date: Tue Aug 9 11:58:01 2011 +0200
modules/db_mysql: Implement affected_rows for mysql
---
modules/db_mysql/km_db_mysql.c | 2 +-
modules/db_mysql/km_dbase.c | 17 ++++++++++++++++-
modules/db_mysql/km_dbase.h | 7 +++++++
3 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/modules/db_mysql/km_db_mysql.c b/modules/db_mysql/km_db_mysql.c
index a94cf77..1f758ba 100644
--- a/modules/db_mysql/km_db_mysql.c
+++ b/modules/db_mysql/km_db_mysql.c
@@ -114,7 +114,7 @@ int db_mysql_bind_api(db_func_t *dbb)
dbb->last_inserted_id = db_mysql_last_inserted_id;
dbb->insert_update = db_mysql_insert_update;
dbb->insert_delayed = db_mysql_insert_delayed;
+ dbb->affected_rows = db_mysql_affected_rows;
return 0;
}
-
diff --git a/modules/db_mysql/km_dbase.c b/modules/db_mysql/km_dbase.c
index 68481f7..d85fe5f 100644
--- a/modules/db_mysql/km_dbase.c
+++ b/modules/db_mysql/km_dbase.c
@@ -480,7 +480,22 @@ int db_mysql_last_inserted_id(const db1_con_t* _h)
}
- /**
+/**
+ * Returns the affected rows of the last query.
+ * \param _h database handle
+ * \return returns the affected rows as integer or -1 on error.
+ */
+int db_mysql_affected_rows(const db1_con_t* _h)
+{
+ if (!_h) {
+ LM_ERR("invalid parameter value\n");
+ return -1;
+ }
+ return (int)mysql_affected_rows(CON_CONNECTION(_h));
+}
+
+
+/**
* Insert a row into a specified table, update on duplicate key.
* \param _h structure representing database connection
* \param _k key names
diff --git a/modules/db_mysql/km_dbase.h b/modules/db_mysql/km_dbase.h
index f7c2d0c..68e4e8e 100644
--- a/modules/db_mysql/km_dbase.h
+++ b/modules/db_mysql/km_dbase.h
@@ -111,6 +111,13 @@ int db_mysql_replace(const db1_con_t* handle, const db_key_t* keys,
const db_val
*/
int db_mysql_last_inserted_id(const db1_con_t* _h);
+
+/*! \brief
+ * Returns number of affected rows for last query
+ */
+int db_mysql_affected_rows(const db1_con_t* _h);
+
+
/*! \brief
* Insert a row into table, update on duplicate key
*/