implemented prepared statement for postgres and sqlite

This commit is contained in:
2023-12-09 11:08:03 +01:00
parent 8ba70cc79e
commit da423ea8bb
59 changed files with 1769 additions and 314 deletions
+55
View File
@@ -0,0 +1,55 @@
#ifndef QUERY_STATEMENT_HPP
#define QUERY_STATEMENT_HPP
#include "matador/sql/object_binder.hpp"
#include "matador/sql/query_result.hpp"
#include "matador/sql/statement_impl.hpp"
#include "matador/utils/logger.hpp"
#include <memory>
namespace matador::sql {
class statement
{
public:
explicit statement(std::unique_ptr<statement_impl> impl, const utils::logger &logger);
template < typename Type >
statement& bind(size_t pos, const Type &value)
{
statement_->bind(pos, value);
return *this;
}
statement& bind(size_t pos, std::string &val, size_t size);
template < class Type >
statement& bind(const Type &obj)
{
object_binder_.reset();
matador::utils::access::process(object_binder_, obj);
return *this;
}
size_t execute();
template<class Type>
query_result<Type> fetch()
{
logger_.info(statement_->query_.sql);
return query_result<Type>(statement_->fetch());
}
query_result<record> fetch();
void reset();
private:
std::unique_ptr<statement_impl> statement_;
const utils::logger &logger_;
object_binder object_binder_;
};
}
#endif //QUERY_STATEMENT_HPP