pica/database/mysql/statement.h
2024-01-21 16:23:48 -03:00

33 lines
720 B
C++

//SPDX-FileCopyrightText: 2023 Yury Gubich <blue@macaw.me>
//SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
#include <cstring>
#include <vector>
#include <tuple>
#include <any>
#include "mysql.h"
namespace DB {
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, bool usigned = false);
void execute();
unsigned int affectedRows();
std::vector<std::vector<std::any>> fetchResult();
private:
std::unique_ptr<MYSQL_STMT, STMTDeleter> stmt;
std::vector<MYSQL_BIND> param;
};
}