mirror of
https://github.com/pocoproject/poco.git
synced 2025-01-21 02:00:33 +01:00
MySQL: Implemented affectedRowCount
This commit is contained in:
parent
ae26e45bad
commit
4ce851672a
@ -85,6 +85,8 @@ public:
|
|||||||
|
|
||||||
bool fetchColumn(std::size_t n, MYSQL_BIND *bind);
|
bool fetchColumn(std::size_t n, MYSQL_BIND *bind);
|
||||||
/// Fetches the column.
|
/// Fetches the column.
|
||||||
|
|
||||||
|
std::size_t getAffectedRowCount() const;
|
||||||
|
|
||||||
operator MYSQL_STMT* ();
|
operator MYSQL_STMT* ();
|
||||||
/// Cast operator to native handle type.
|
/// Cast operator to native handle type.
|
||||||
@ -95,9 +97,10 @@ private:
|
|||||||
StatementExecutor& operator=(const StatementExecutor&);
|
StatementExecutor& operator=(const StatementExecutor&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
MYSQL* _pSessionHandle;
|
||||||
MYSQL_STMT* _pHandle;
|
MYSQL_STMT* _pHandle;
|
||||||
int _state;
|
int _state;
|
||||||
|
std::size_t _affectedRowCount;
|
||||||
std::string _query;
|
std::string _query;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ std::size_t MySQLStatementImpl::columnsReturned() const
|
|||||||
|
|
||||||
std::size_t MySQLStatementImpl::affectedRowCount() const
|
std::size_t MySQLStatementImpl::affectedRowCount() const
|
||||||
{
|
{
|
||||||
return 0;
|
return _stmt.getAffectedRowCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,6 +45,8 @@ namespace MySQL {
|
|||||||
|
|
||||||
|
|
||||||
StatementExecutor::StatementExecutor(MYSQL* mysql)
|
StatementExecutor::StatementExecutor(MYSQL* mysql)
|
||||||
|
: _pSessionHandle(mysql)
|
||||||
|
, _affectedRowCount(0)
|
||||||
{
|
{
|
||||||
if (!(_pHandle = mysql_stmt_init(mysql)))
|
if (!(_pHandle = mysql_stmt_init(mysql)))
|
||||||
throw StatementException("mysql_stmt_init error");
|
throw StatementException("mysql_stmt_init error");
|
||||||
@ -115,6 +117,8 @@ void StatementExecutor::execute()
|
|||||||
throw StatementException("mysql_stmt_execute error", _pHandle, _query);
|
throw StatementException("mysql_stmt_execute error", _pHandle, _query);
|
||||||
|
|
||||||
_state = STMT_EXECUTED;
|
_state = STMT_EXECUTED;
|
||||||
|
|
||||||
|
_affectedRowCount = mysql_affected_rows(_pSessionHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -149,5 +153,10 @@ bool StatementExecutor::fetchColumn(std::size_t n, MYSQL_BIND *bind)
|
|||||||
return (res == 0);
|
return (res == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::size_t StatementExecutor::getAffectedRowCount() const
|
||||||
|
{
|
||||||
|
return _affectedRowCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}}}
|
}}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user