1
0
forked from blue/pica
pica/database/mysql/statement.h

33 lines
720 B
C
Raw Normal View History

2023-12-30 19:42:11 -03:00
//SPDX-FileCopyrightText: 2023 Yury Gubich <blue@macaw.me>
//SPDX-License-Identifier: GPL-3.0-or-later
2023-12-08 19:26:16 -03:00
#pragma once
2023-12-23 17:23:38 -03:00
#include <cstring>
2023-12-08 19:26:16 -03:00
#include <vector>
2023-12-23 17:23:38 -03:00
#include <tuple>
#include <any>
2023-12-08 19:26:16 -03:00
#include "mysql.h"
2023-12-29 14:40:00 -03:00
namespace DB {
2023-12-08 19:26:16 -03:00
class MySQL::Statement {
struct STMTDeleter {
void operator () (MYSQL_STMT* stmt) {
mysql_stmt_close(stmt);
};
};
public:
Statement(MYSQL* connection, const char* statement);
2023-12-20 19:42:13 -03:00
void bind(void* value, enum_field_types type, bool usigned = false);
2023-12-08 19:26:16 -03:00
void execute();
2024-01-21 16:23:48 -03:00
unsigned int affectedRows();
2023-12-23 17:23:38 -03:00
std::vector<std::vector<std::any>> fetchResult();
2023-12-08 19:26:16 -03:00
private:
std::unique_ptr<MYSQL_STMT, STMTDeleter> stmt;
std::vector<MYSQL_BIND> param;
};
2023-12-29 14:40:00 -03:00
}