mirror of
https://github.com/Jackzmc/sourcemod-plugins.git
synced 2025-05-06 21:43:22 +00:00
Only create transaction when we use it
This commit is contained in:
parent
d397b1e10d
commit
1148a2b689
1 changed files with 5 additions and 4 deletions
|
@ -158,8 +158,9 @@ public Action Timer_PushLogs(Handle h) {
|
||||||
static char query[1024];
|
static char query[1024];
|
||||||
static Log log;
|
static Log log;
|
||||||
int length = logs.Length;
|
int length = logs.Length;
|
||||||
Transaction transaction = new Transaction();
|
|
||||||
if(length > 0) {
|
if(length > 0) {
|
||||||
|
Transaction transaction = new Transaction();
|
||||||
for(int i = 0; i < length; i++) {
|
for(int i = 0; i < length; i++) {
|
||||||
logs.GetArray(i, log, sizeof(log));
|
logs.GetArray(i, log, sizeof(log));
|
||||||
g_db.Format(query, sizeof(query), "INSERT INTO `activity_log` (`timestamp`, `server`, `type`, `client`, `target`, `message`) VALUES (%d, NULLIF('%s', ''), '%s', NULLIF('%s', ''), NULLIF('%s', ''), NULLIF('%s', ''))",
|
g_db.Format(query, sizeof(query), "INSERT INTO `activity_log` (`timestamp`, `server`, `type`, `client`, `target`, `message`) VALUES (%d, NULLIF('%s', ''), '%s', NULLIF('%s', ''), NULLIF('%s', ''), NULLIF('%s', ''))",
|
||||||
|
@ -173,11 +174,11 @@ public Action Timer_PushLogs(Handle h) {
|
||||||
transaction.AddQuery(query);
|
transaction.AddQuery(query);
|
||||||
}
|
}
|
||||||
logs.Resize(logs.Length - length);
|
logs.Resize(logs.Length - length);
|
||||||
|
g_db.Execute(transaction, _, SQL_TransactionFailed, length, DBPrio_Low);
|
||||||
}
|
}
|
||||||
g_db.Execute(transaction, _, SQL_TransactionFailed, length, DBPrio_Low);
|
|
||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
}
|
}
|
||||||
public void SQL_TransactionFailed(Database db, any data, int numQueries, const char[] error, int failIndex, any[] queryData) {
|
void SQL_TransactionFailed(Database db, any data, int numQueries, const char[] error, int failIndex, any[] queryData) {
|
||||||
LogError("Push transaction failed: %s at query %d/%d", error, failIndex, numQueries);
|
LogError("Push transaction failed: %s at query %d/%d", error, failIndex, numQueries);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue