UniSet  2.8.0
MySQLInterface.h
1 /*
2  * Copyright (c) 2015 Pavel Vainerman.
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as
6  * published by the Free Software Foundation, version 2.1.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * Lesser General Lesser Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  */
16 // --------------------------------------------------------------------------
20 //----------------------------------------------------------------------------
21 #ifndef MySQLInterface_H_
22 #define MySQLInterface_H_
23 // ---------------------------------------------------------------------------
24 #include <string>
25 #include <vector>
26 #include <deque>
27 #include <iostream>
28 //#warning Для использования mysql_create нужен define USE_OLD_FUNCTIONS
29 //#define USE_OLD_FUNCTIONS
30 #include <mysql/mysql.h>
31 #include <DBInterface.h>
32 // -------------------------------------------------------------------------
33 namespace uniset
34 {
35  // ----------------------------------------------------------------------------
37  public DBNetInterface
38  {
39  public:
40 
42  ~MySQLInterface();
43 
44  // DBResult listFields( const std::string& table, const std::string& wild );
45 
46  virtual bool nconnect( const std::string& host, const std::string& user, const std::string& pswd,
47  const std::string& dbname, unsigned int port = 0 ) override;
48  virtual bool close() override;
49 
50  bool query_ok( const std::string& q );
51 
52  // \param finalize - освободить буфер после запроса
53  virtual DBResult query( const std::string& q ) override;
54 
55  virtual const std::string lastQuery() override;
56  virtual bool insert( const std::string& q ) override;
57 
58  std::string addslashes(const std::string& str);
59 
64  virtual bool ping() const override;
65 
67  virtual bool isConnection() const override;
68 
69  virtual double insert_id() override;
70 
71  virtual const std::string error() override;
72 
73  // *******************
74  const char* gethostinfo() const;
75  protected:
76 
77  private:
78 
79  DBResult makeResult( MYSQL_RES* r, bool finalize = true );
80  MYSQL* mysql;
81  std::string lastQ;
82  bool connected;
83  };
84  // ----------------------------------------------------------------------------------
85 } // end of namespace uniset
86 // ----------------------------------------------------------------------------------
87 #endif
Definition: CommonEventLoop.h:14
virtual bool ping() const override
Definition: MySQLInterface.cc:150
Definition: DBInterface.h:36
Definition: MySQLInterface.h:36
virtual bool isConnection() const override
Definition: MySQLInterface.cc:160
Definition: DBInterface.h:51