diff options
| author | Paul Buetow <paul@buetow.org> | 2013-04-06 13:14:42 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2013-04-06 13:14:42 +0200 |
| commit | 98eac951f8087b213f5850bd126dcb279db360a8 (patch) | |
| tree | c121f5c4df1aab847defa539990c1315bd5ba4a8 /mcon.cpp | |
| parent | 0537da9d1e0f593130fc3967befb71e673b016bc (diff) | |
tagging ychat-0.6ychat-0.6
Diffstat (limited to 'mcon.cpp')
| -rw-r--r-- | mcon.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/mcon.cpp b/mcon.cpp new file mode 100644 index 0000000..bdea95e --- /dev/null +++ b/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 |
