00001 // LICENSE: (Please see the file COPYING for details) 00002 // 00003 // NUS - Nemesis Utilities System: A C++ application development framework 00004 // Copyright (C) 2006, 2008 Otavio Rodolfo Piske 00005 // 00006 // This file is part of NUS 00007 // 00008 // This library is free software; you can redistribute it and/or 00009 // modify it under the terms of the GNU Lesser General Public 00010 // License as published by the Free Software Foundation version 2.1 00011 // of the License. 00012 // 00013 // This library is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 // Lesser General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU Lesser General Public 00019 // License along with this library; if not, write to the Free Software 00020 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00021 // 00022 #ifndef NMYSQL_H_ 00023 #define NMYSQL_H_ 00024 00025 #include "nobject.h" 00026 #include "nstring.h" 00027 #include "nhostaddress.h" 00028 #include "nsql.h" 00029 #include "nsqlquery.h" 00030 #include "nsqlrecord.h" 00031 #include "nsqlresultset.h" 00032 00033 #include <mysql.h> 00034 #include <errmsg.h> 00035 00036 00050 class NMySql: public NSql { 00051 public: 00052 NMySql(void); 00053 NMySql(const NString &user, const NString &pass, 00054 const NHostAddress &host); 00055 NMySql(const NString &user, const NString &pass, 00056 const NHostAddress &host, nint16 port); 00057 ~NMySql(void); 00058 00059 00060 void connectToHost(void); 00061 void disconnectFromHost(void); 00062 bool execSql(const NSqlQuery &query); 00063 00064 NSqlRecord *getNext(void); 00065 NSqlRecord *getPrevious(void); 00066 NSqlRecord *getFirst(void); 00067 NSqlRecord *getLast(void); 00068 00069 NString getError(void) const; 00070 00071 private: 00072 NMySql(const NMySql &other); 00073 NMySql &operator=(const NMySql &rhs); 00074 00075 MYSQL *m_handle; 00076 NSqlResultSet m_resultSet; 00077 nuint64 m_pos; 00078 bool m_connected; 00079 00080 void init(void); 00081 00082 void clearResultSet(void); 00083 NSqlRecord *loadRow(MYSQL_RES *result, MYSQL_ROW row); 00084 void loadResultSet(void); 00085 00086 NString getDetailedError(void) const; 00087 00088 00089 00090 }; 00091 00092 #endif // NMYSQL_H_