From 9cd3ccffd5372dfde3af478e3f832f18db4be3f1 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 6 Apr 2013 13:14:41 +0200 Subject: tagging tags --- ychat-0.6/mcon.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 ychat-0.6/mcon.cpp (limited to 'ychat-0.6/mcon.cpp') diff --git a/ychat-0.6/mcon.cpp b/ychat-0.6/mcon.cpp new file mode 100644 index 0000000..bdea95e --- /dev/null +++ b/ychat-0.6/mcon.cpp @@ -0,0 +1,40 @@ +#ifndef MCON_CXX +#define MCON_CXX + +#include "mcon.h" + +mcon::mcon( MYSQL *mysql ) +{ + this->query_sent=false; + if(mysql==NULL) + cerr << "Warning: mysql seems 0" << endl; + this->myc=mysql; +} +mcon::~mcon() +{ + if(this->query_sent) + mysql_free_result(this->current_result); +} +int mcon::query( string query ) +{ + mysql_real_query( this->myc, query.c_str(), query.size() ); + + if(mysql_error(this->myc)[0] != '\0') + { + cerr << "MySQL error occured: " << mysql_error(this->myc) << endl; + return -1; + } + this->query_sent=true; + + this->current_result=mysql_store_result( this->myc ); +} +MYSQL_ROW mcon::get_next_row() +{ + if(query_sent) + { + return mysql_fetch_row( this->current_result ); + } + + return NULL; +} +#endif -- cgit v1.2.3