summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorpixel <pixel>2007-04-12 18:07:17 +0000
committerpixel <pixel>2007-04-12 18:07:17 +0000
commitd8b98aa297f68e579b8ec98ee12d98fc64315318 (patch)
tree7b6f1a0603f1d7976d2cdf50df9e2d949182699a /lib
parent4d4cc691c8a70d31c1965145d27d68becd42f790 (diff)
Adding numaffectedrows() and insertid() into the SQL class. Also having
a slightly better error support. Need more work on that though.
Diffstat (limited to 'lib')
-rw-r--r--lib/SQL.cc14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/SQL.cc b/lib/SQL.cc
index 26620e4..e599f95 100644
--- a/lib/SQL.cc
+++ b/lib/SQL.cc
@@ -34,6 +34,8 @@ void SQLConnection::query(String q) throw(GeneralException) {
mysql_free_result(res);
}
+ res = 0;
+
if (mysql_real_query(&con, ((ugly_string)q).p, q.strlen())) {
throw GeneralException(String("Couldn't run query ") + q);
}
@@ -44,10 +46,14 @@ void SQLConnection::query(String q) throw(GeneralException) {
nr = mysql_num_rows(res);
nf = mysql_num_fields(res);
fields = mysql_fetch_fields(res);
+ na = mysql_affected_rows(res);
+ ii = mysql_insert_id(res);
} else {
nr = 0;
nf = 0;
fields = 0;
+ na = 0;
+ ii = -1;
}
}
@@ -73,4 +79,12 @@ AssocArray SQLConnection::fetchrow() {
return r;
}
+int SQLConnection::numaffectedrows() {
+ return na;
+}
+
+int SQLConnection::insertid() {
+ return ii;
+}
+
#endif