pica/database/mysql/statement.h

28 lines
583 B
C++

// SPDX-FileCopyrightText: 2023 Yury Gubich <blue@macaw.me>
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
#include <vector>
#include "mysql.h"
class MySQL::Statement {
struct STMTDeleter {
void operator () (MYSQL_STMT* stmt) {
mysql_stmt_close(stmt);
};
};
public:
Statement(MYSQL* connection, const char* statement);
void bind(void* value, enum_field_types type);
void execute();
private:
std::unique_ptr<MYSQL_STMT, STMTDeleter> stmt;
std::vector<MYSQL_BIND> param;
std::vector<uint64_t> lengths;
};