summaryrefslogtreecommitdiff
path: root/lib/SQL.cc
diff options
context:
space:
mode:
authorpixel <pixel>2004-11-27 21:35:19 +0000
committerpixel <pixel>2004-11-27 21:35:19 +0000
commit3f7070bf177b743be0eeb8c404a620f72eb15ab6 (patch)
treea22fa7d0a1fd362bfc858f8e7e2062fdd5b252ce /lib/SQL.cc
parent6ba597d46a93aaa9a17eb8a9fe8f3bcdedf686c0 (diff)
Large dos2unix commit...
Diffstat (limited to 'lib/SQL.cc')
-rw-r--r--lib/SQL.cc152
1 files changed, 76 insertions, 76 deletions
diff --git a/lib/SQL.cc b/lib/SQL.cc
index 26620e4..7c1bc96 100644
--- a/lib/SQL.cc
+++ b/lib/SQL.cc
@@ -1,76 +1,76 @@
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#ifdef HAVE_MYSQL
-
-#include "SQL.h"
-
-SQLConnection::SQLConnection(String host, String user, String passwd,
- String db, int port, String socket,
- unsigned long cflags) throw (GeneralException) : res(0) {
- mysql_init(&con);
-
- const char * phost = ((ugly_string) host).p;
- const char * puser = ((ugly_string) user).p;
- const char * ppasswd = ((ugly_string) passwd).p;
- const char * pdb = ((ugly_string) db).p;
- const char * psocket = ((ugly_string) socket).p;
-
- phost = *phost ? phost : 0;
- psocket = *psocket ? psocket : 0;
-
- if (!mysql_real_connect(&con, phost, puser, ppasswd, pdb, port, psocket, cflags)) {
- throw GeneralException("Could not connect to MySQL host " + host);
- }
-}
-
-SQLConnection::~SQLConnection() {
- mysql_close(&con);
-}
-
-void SQLConnection::query(String q) throw(GeneralException) {
- if (res) {
- mysql_free_result(res);
- }
-
- if (mysql_real_query(&con, ((ugly_string)q).p, q.strlen())) {
- throw GeneralException(String("Couldn't run query ") + q);
- }
-
- res = mysql_store_result(&con);
-
- if (res) {
- nr = mysql_num_rows(res);
- nf = mysql_num_fields(res);
- fields = mysql_fetch_fields(res);
- } else {
- nr = 0;
- nf = 0;
- fields = 0;
- }
-}
-
-int SQLConnection::numrows() {
- return nr;
-}
-
-int SQLConnection::numfields() {
- return nf;
-}
-
-AssocArray SQLConnection::fetchrow() {
- AssocArray r;
- MYSQL_ROW row;
- int i;
-
- row = mysql_fetch_row(res);
-
- for (i = 0; i < nf; i++) {
- r[fields[i].name] = row[i];
- }
-
- return r;
-}
-
-#endif
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef HAVE_MYSQL
+
+#include "SQL.h"
+
+SQLConnection::SQLConnection(String host, String user, String passwd,
+ String db, int port, String socket,
+ unsigned long cflags) throw (GeneralException) : res(0) {
+ mysql_init(&con);
+
+ const char * phost = ((ugly_string) host).p;
+ const char * puser = ((ugly_string) user).p;
+ const char * ppasswd = ((ugly_string) passwd).p;
+ const char * pdb = ((ugly_string) db).p;
+ const char * psocket = ((ugly_string) socket).p;
+
+ phost = *phost ? phost : 0;
+ psocket = *psocket ? psocket : 0;
+
+ if (!mysql_real_connect(&con, phost, puser, ppasswd, pdb, port, psocket, cflags)) {
+ throw GeneralException("Could not connect to MySQL host " + host);
+ }
+}
+
+SQLConnection::~SQLConnection() {
+ mysql_close(&con);
+}
+
+void SQLConnection::query(String q) throw(GeneralException) {
+ if (res) {
+ mysql_free_result(res);
+ }
+
+ if (mysql_real_query(&con, ((ugly_string)q).p, q.strlen())) {
+ throw GeneralException(String("Couldn't run query ") + q);
+ }
+
+ res = mysql_store_result(&con);
+
+ if (res) {
+ nr = mysql_num_rows(res);
+ nf = mysql_num_fields(res);
+ fields = mysql_fetch_fields(res);
+ } else {
+ nr = 0;
+ nf = 0;
+ fields = 0;
+ }
+}
+
+int SQLConnection::numrows() {
+ return nr;
+}
+
+int SQLConnection::numfields() {
+ return nf;
+}
+
+AssocArray SQLConnection::fetchrow() {
+ AssocArray r;
+ MYSQL_ROW row;
+ int i;
+
+ row = mysql_fetch_row(res);
+
+ for (i = 0; i < nf; i++) {
+ r[fields[i].name] = row[i];
+ }
+
+ return r;
+}
+
+#endif