Skip to content

Commit

Permalink
fixed prune sql
Browse files Browse the repository at this point in the history
  • Loading branch information
LMOspaceace committed Feb 1, 2016
1 parent 36254bf commit f6d33db
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions acp/ajaxchat_module.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,18 +199,16 @@ public function prune_chat($value, $key)
}
if ($this->u_action === 'prune_chat')
{
$sql = 'SELECT message_id
FROM ' . CHAT_TABLE . '
ORDER BY message_id DESC ';
$result = $this->db->sql_query_limit($sql, $this->config['prune_keep_ajax_chat'], 1);
$row = $this->db->sql_fetchrow($result);
$sql = 'SELECT message_id
FROM ' . CHAT_TABLE . '
ORDER BY message_id DESC ';
$result = $this->db->sql_query_limit($sql, 1, $this->config['prune_keep_ajax_chat']);
$row = $this->db->sql_fetchfield('message_id');
$this->db->sql_freeresult($result);
$sql1 = 'DELETE FROM ' . CHAT_TABLE . '
WHERE `message_id` < ' . (int) $row['message_id'] . '';
WHERE `message_id` <= ' . (int) $row . '';
$this->db->sql_query($sql1);

add_log('admin', 'PRUNE_LOG_AJAXCHAT');

if ($this->request->is_ajax())
{
trigger_error($this->user->lang['PRUNE_CHAT_SUCCESS']);
Expand Down Expand Up @@ -252,8 +250,6 @@ public function truncate_chat($value, $key)
$sql1 = 'TRUNCATE ' . CHAT_TABLE . '';
$this->db->sql_query($sql1);

add_log('admin', 'TRUNCATE_LOG_AJAXCHAT');

if ($this->request->is_ajax())
{
trigger_error($this->user->lang['TRUNCATE_CHAT_SUCCESS']);
Expand Down

0 comments on commit f6d33db

Please sign in to comment.