UniSet
1.4.0
|
00001 /* This file is part of the UniSet project 00002 * Copyright (c) 2002 Free Software Foundation, Inc. 00003 * Copyright (c) 2002 Pavel Vainerman 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 */ 00019 // -------------------------------------------------------------------------- 00023 //---------------------------------------------------------------------------- 00024 #ifndef DBInterface_H_ 00025 #define DBInterface_H_ 00026 // --------------------------------------------------------------------------- 00027 #include <string> 00028 #include <iostream> 00029 //#warning Для использования mysql_create нужен define USE_OLD_FUNCTIONS 00030 //#define USE_OLD_FUNCTIONS 00031 #include <mysql/mysql.h> 00032 using std::string; 00033 // ---------------------------------------------------------------------------- 00034 class DBInterface 00035 { 00036 public: 00037 00038 DBInterface(); 00039 ~DBInterface(); 00040 00041 // bool createDB(const string dbname); 00042 // bool dropDB(const string dbname); 00043 MYSQL_RES * listFields(const string table, const string wild ); 00044 00045 00046 bool connect( const string host, const string user, const string pswd, 00047 const string dbname); 00048 bool close(); 00049 00050 bool query(const string q); 00051 const string lastQuery(); 00052 bool insert(const string q); 00053 00054 string addslashes(const string& str); 00055 00060 bool ping(); 00061 00063 bool isConnection(); 00064 00065 bool nextRecord(); 00066 void freeResult(); 00067 00068 unsigned int numCols(); 00069 unsigned int numRows(); 00070 00071 bool moveToRow(int ind); 00072 00073 int insert_id(); 00074 00075 const MYSQL_ROW getRow(); 00076 const string error(); 00077 00078 MYSQL_ROW Row; 00079 00080 // ******************* 00081 const char* gethostinfo(); 00082 protected: 00083 00084 private: 00085 00086 MYSQL_RES *result; 00087 MYSQL *mysql; 00088 string lastQ; 00089 bool queryok; // успешность текущего запроса 00090 bool connected; 00091 }; 00092 // ---------------------------------------------------------------------------------- 00093 #endif