56 lines
1.1 KiB
C++
56 lines
1.1 KiB
C++
#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
|