1
0
Fork 0

Clean out the viewers table every 5 minutes.

This commit is contained in:
Andrew Tomaka 2011-11-05 16:10:30 -04:00
parent 035ed81542
commit d79162a889
2 changed files with 14 additions and 1 deletions

View file

@ -1,10 +1,17 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class View extends CI_Controller { class View extends CI_Controller {
function __construct() {
parent::__construct();
$this->load->model('viewer');
$this->viewer->clean_viewers(5 * 60);
}
public function index() { public function index() {
} }
public function specific() { public function specific() {
$this->load->model('fileupload'); $this->load->model('fileupload');

View file

@ -23,6 +23,12 @@ class Viewer extends CI_Model {
return false; return false;
} }
} }
function clean_viewers($duration) {
$clean_time = time() - $duration;
$this->db->query("DELETE FROM viewers WHERE timestamp < $clean_time");
}
} }
?> ?>