# DbClient.hpp

This File On Github
Ask A Question

API: latest
module: oatpp
#include "oatpp/orm/DbClient.hpp"

# DbClient

Database client.

namespace oatpp { namespace orm { 
  class DbClient {}
}}

# Methods

Return Type Name Summary
[none] DbClient Constructor.
[none] ~DbClient Virtual destructor.
std::shared_ptr<Connection> getConnection Get database connection.
void setEnabledInterpretations Set enabled type interpretations.
std::shared_ptr<const data::mapping::TypeResolver> getTypeResolver Get type resolver.
data::share::StringTemplate parseQueryTemplate Parse query template.
std::shared_ptr<QueryResult> execute Execute query using template.
std::shared_ptr<QueryResult> executeQuery Execute arbitrary query.
Transaction beginTransaction Begin database transaction.

# DbClient::DbClient

Constructor.

DbClient(const std::shared_ptr<Executor>& executor)

# DbClient::~DbClient

Virtual destructor.

virtual ~DbClient() = default

# DbClient::getConnection

Get database connection.

  • @return

std::shared_ptr<Connection> getConnection()

# DbClient::setEnabledInterpretations

Set enabled type interpretations.

  • @param enabledInterpretations

void setEnabledInterpretations(const std::vector<std::string>& enabledInterpretations)

# DbClient::getTypeResolver

Get type resolver.

std::shared_ptr<const data::mapping::TypeResolver> getTypeResolver()

# DbClient::parseQueryTemplate

Parse query template.

  • @param name - template name.
  • @param text - template text.
  • @param paramsTypeMap - template parameter types.
  • @param prepare - true if the query should use prepared statement, false otherwise.
  • @return - oatpp::data::share::StringTemplate.

data::share::StringTemplate parseQueryTemplate(const oatpp::String& name,
                                               const oatpp::String& text,
                                               const Executor::ParamsTypeMap& paramsTypeMap,
                                               bool prepare = false)

# DbClient::execute

Execute query using template.

std::shared_ptr<QueryResult> execute(const data::share::StringTemplate& queryTemplate,
                                     const std::unordered_map<oatpp::String, oatpp::Void>& params,
                                     const std::shared_ptr<Connection>& connection = nullptr)

# DbClient::executeQuery

Execute arbitrary query.

  • @param query - query text.
  • @param params - query parameters.
  • @param connection - database connection.
  • @return - oatpp::orm::QueryResult.

std::shared_ptr<QueryResult> executeQuery(const oatpp::String& query,
                                          const std::unordered_map<oatpp::String, oatpp::Void>& params,
                                          const std::shared_ptr<Connection>& connection = nullptr)

# DbClient::beginTransaction

Begin database transaction.

Transaction beginTransaction(const std::shared_ptr<Connection>& connection = nullptr)