UniSet  2.2.1
MySQLInterface.h
См. документацию.
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 MySQLInterface_H_
00025 #define MySQLInterface_H_
00026 // ---------------------------------------------------------------------------
00027 #include <string>
00028 #include <vector>
00029 #include <deque>
00030 #include <iostream>
00031 //#warning Для использования mysql_create нужен define USE_OLD_FUNCTIONS
00032 //#define USE_OLD_FUNCTIONS
00033 #include <mysql/mysql.h>
00034 #include <DBInterface.h>
00035 // ----------------------------------------------------------------------------
00036 class MySQLInterface:
00037     public DBNetInterface
00038 {
00039     public:
00040 
00041         MySQLInterface();
00042         ~MySQLInterface();
00043 
00044         //            DBResult listFields( const std::string& table, const std::string& wild );
00045 
00046         virtual bool nconnect( const std::string& host, const std::string& user, const std::string& pswd,
00047                                const std::string& dbname) override;
00048         virtual bool close() override;
00049 
00050         bool query_ok( const std::string& q );
00051 
00052         // \param finalize - освободить буфер после запроса
00053         virtual DBResult query( const std::string& q ) override;
00054 
00055         virtual const std::string lastQuery() override;
00056         virtual bool insert( const std::string& q ) override;
00057 
00058         std::string addslashes(const std::string& str);
00059 
00064         virtual bool ping() override;
00065 
00067         virtual bool isConnection() override;
00068 
00069         virtual double insert_id() override;
00070 
00071         virtual const std::string error() override;
00072 
00073         // *******************
00074         const char* gethostinfo();
00075     protected:
00076 
00077     private:
00078 
00079         void makeResult(DBResult& dbres, MYSQL_RES* r, bool finalize = true );
00080         MYSQL* mysql;
00081         std::string lastQ;
00082         bool connected;
00083 };
00084 // ----------------------------------------------------------------------------------
00085 #endif