Browse code

modules/db_mysql: Implement affected_rows for mysql

Alex Hermann authored on 09/08/2011 09:58:01
Showing 3 changed files
... ...
@@ -114,7 +114,7 @@ int db_mysql_bind_api(db_func_t *dbb)
114 114
 	dbb->last_inserted_id = db_mysql_last_inserted_id;
115 115
 	dbb->insert_update    = db_mysql_insert_update;
116 116
 	dbb->insert_delayed   = db_mysql_insert_delayed;
117
+	dbb->affected_rows    = db_mysql_affected_rows;
117 118
 
118 119
 	return 0;
119 120
 }
120
-
... ...
@@ -480,7 +480,22 @@ int db_mysql_last_inserted_id(const db1_con_t* _h)
480 480
 }
481 481
 
482 482
 
483
- /**
483
+/**
484
+ * Returns the affected rows of the last query.
485
+ * \param _h database handle
486
+ * \return returns the affected rows as integer or -1 on error.
487
+ */
488
+int db_mysql_affected_rows(const db1_con_t* _h)
489
+{
490
+	if (!_h) {
491
+		LM_ERR("invalid parameter value\n");
492
+		return -1;
493
+	}
494
+	return (int)mysql_affected_rows(CON_CONNECTION(_h));
495
+}
496
+
497
+
498
+/**
484 499
   * Insert a row into a specified table, update on duplicate key.
485 500
   * \param _h structure representing database connection
486 501
   * \param _k key names
... ...
@@ -111,6 +111,13 @@ int db_mysql_replace(const db1_con_t* handle, const db_key_t* keys, const db_val
111 111
  */
112 112
 int db_mysql_last_inserted_id(const db1_con_t* _h);
113 113
 
114
+
115
+/*! \brief
116
+ * Returns number of affected rows for last query
117
+ */
118
+int db_mysql_affected_rows(const db1_con_t* _h);
119
+
120
+
114 121
 /*! \brief
115 122
  * Insert a row into table, update on duplicate key
116 123
  */