AnCH Framework 0.2
Another C++ Hack: C++23 utility libraries
Loading...
Searching...
No Matches
mysqlConnection.hpp
1/*
2 ANCH Framework: ANother C++ Hack is a C++ framework based on C++23 standard
3 Copyright (C) 2012 Vincent Lachenal
4
5 This file is part of ANCH Framework.
6
7 ANCH Framework is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 ANCH Framework is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with ANCH Framework. If not, see <https://www.gnu.org/licenses/>.
19*/
20#ifdef ANCH_SQL_MYSQL
21#pragma once
22
23#include "anch-mysql-export.hpp"
24
25#include <string>
26#include <functional>
27#include "mysql.h"
28
29#include "sql/connection.hpp"
30
31//typedef struct st_mysql MYSQL;
32//struct MYSQL;
33
34namespace anch::sql::mysql {
35
46 ANCH_MYSQL_EXPORT bool isFatal(unsigned int code) noexcept;
47
59 ANCH_MYSQL_EXPORT SqlException error(const std::string& message, unsigned int code, const char* text);
60
61} // anch::sql::mysql
62
63namespace anch::sql {
64
74 class ANCH_MYSQL_EXPORT MySQLConnection: public Connection {
75
76 // Attributes +
77 private:
79 MYSQL* _mysql;
80 // Attributes -
81
82 // Constructors +
83 public:
92
97 // Constructors -
98
99 // Destructor +
103 virtual ~MySQLConnection() noexcept;
104 // Destructor -
105
106 // Methods +
107 protected:
117 virtual ResultSet* executeQuery(const std::string& query) override;
118
128 virtual uint64_t executeUpdate(const std::string& query) override;
129
135 virtual void sendCommit() override;
136
142 virtual void sendRollback() override;
143
149 virtual void sendStartTransaction() override;
150
160 virtual PreparedStatement* makePrepared(const std::string& query) override;
161 // Methods -
162
163 };
164
165} // anch::sql
166
167#endif // ANCH_SQL_MYSQL
ResultSet * query(const std::string &query)
Connection(std::size_t statementCacheSize=DEFAULT_STATEMENT_CACHE_SIZE)
virtual ResultSet * executeQuery(const std::string &query) override
virtual void sendRollback() override
MySQLConnection(const MySQLConnection &)
virtual void sendStartTransaction() override
virtual uint64_t executeUpdate(const std::string &query) override
virtual void sendCommit() override
virtual ~MySQLConnection() noexcept
virtual PreparedStatement * makePrepared(const std::string &query) override
MySQLConnection(const SqlConnectionConfiguration &config)
SQL namespace.
Definition clauses.hpp:28
SQL database connection configuration.
Definition connection.hpp:55