TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
PreparedStatementTask Class Reference

#include <PreparedStatement.h>

Public Member Functions

 PreparedStatementTask (PreparedStatement *stmt, bool async=false)
 
 ~PreparedStatementTask ()
 
bool Execute () override
 
PreparedQueryResultFuture GetFuture ()
 
- Public Member Functions inherited from SQLOperation
 SQLOperation ()
 
virtual ~SQLOperation ()
 
virtual int call ()
 
virtual void SetConnection (MySQLConnection *con)
 

Protected Attributes

PreparedStatementm_stmt
 
bool m_has_result
 
PreparedQueryResultPromisem_result
 

Additional Inherited Members

- Public Attributes inherited from SQLOperation
MySQLConnection * m_conn
 

Constructor & Destructor Documentation

PreparedStatementTask::PreparedStatementTask ( PreparedStatement stmt,
bool  async = false 
)
469  :
470 m_stmt(stmt), m_result(nullptr)
471 {
472  m_has_result = async; // If it's async, then there's a result
473  if (async)
475 }
PreparedStatement * m_stmt
Definition: PreparedStatement.h:172
std::promise< PreparedQueryResult > PreparedQueryResultPromise
Definition: Callback.h:27
bool m_has_result
Definition: PreparedStatement.h:173
PreparedQueryResultPromise * m_result
Definition: PreparedStatement.h:174
PreparedStatementTask::~PreparedStatementTask ( )
478 {
479  delete m_stmt;
480  if (m_has_result && m_result != nullptr)
481  delete m_result;
482 }
PreparedStatement * m_stmt
Definition: PreparedStatement.h:172
bool m_has_result
Definition: PreparedStatement.h:173
PreparedQueryResultPromise * m_result
Definition: PreparedStatement.h:174

Member Function Documentation

bool PreparedStatementTask::Execute ( )
overridevirtual

Implements SQLOperation.

485 {
486  if (m_has_result)
487  {
488  PreparedResultSet* result = m_conn->Query(m_stmt);
489  if (!result || !result->GetRowCount())
490  {
491  delete result;
492  m_result->set_value(PreparedQueryResult(NULL));
493  return false;
494  }
495  m_result->set_value(PreparedQueryResult(result));
496  return true;
497  }
498 
499  return m_conn->Execute(m_stmt);
500 }
PreparedStatement * m_stmt
Definition: PreparedStatement.h:172
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
arena_t NULL
Definition: jemalloc_internal.h:624
MySQLConnection * m_conn
Definition: SQLOperation.h:70
uint64 GetRowCount() const
Definition: QueryResult.h:70
bool m_has_result
Definition: PreparedStatement.h:173
PreparedQueryResultPromise * m_result
Definition: PreparedStatement.h:174
Definition: QueryResult.h:63

+ Here is the call graph for this function:

PreparedQueryResultFuture PreparedStatementTask::GetFuture ( )
inline
169 { return m_result->get_future(); }
PreparedQueryResultPromise * m_result
Definition: PreparedStatement.h:174

+ Here is the caller graph for this function:

Member Data Documentation

bool PreparedStatementTask::m_has_result
protected
PreparedQueryResultPromise* PreparedStatementTask::m_result
protected
PreparedStatement* PreparedStatementTask::m_stmt
protected

The documentation for this class was generated from the following files: