IdoMysqlConnection: Store last notifications insert id.

refs #4768
This commit is contained in:
Michael Friedrich 2013-10-01 12:45:09 +02:00
parent 16de7f853b
commit 5d15e3b644
2 changed files with 9 additions and 0 deletions

View File

@ -339,6 +339,10 @@ bool IdoMysqlConnection::FieldToEscapedString(const String& key, const Value& va
*result = static_cast<long>(m_InstanceID);
return true;
}
if (key == "notification_id") {
*result = static_cast<long>(m_LastNotificationID);
return true;
}
Value rawvalue = DbValue::ExtractValue(value);
@ -503,6 +507,10 @@ void IdoMysqlConnection::ExecuteQuery(const DbQuery& query)
if (type == DbQueryInsert && query.ConfigUpdate)
SetInsertID(query.Object, GetLastInsertID());
}
if (type == DbQueryInsert && query.Table == "notifications") { // FIXME remove hardcoded table name
m_LastNotificationID = GetLastInsertID();
Log(LogWarning, "db_ido", "saving contactnotification notification_id=" + Convert::ToString(static_cast<long>(m_LastNotificationID)));
}
}
void IdoMysqlConnection::CleanUpExecuteQuery(const String& table, const String& time_key, double time_value)

View File

@ -63,6 +63,7 @@ private:
String m_InstanceDescription;
DbReference m_InstanceID;
DbReference m_LastNotificationID;
boost::mutex m_ConnectionMutex;
bool m_Connected;