[eluser]Dunmail[/eluser]
I've a simple application written using Codeigniter and Datamapper which is used to record details of races. All well and good until the point at which the runners are logged crossing the finish line.
The controller reads the next finisher's position out of a session variable and passes it to the view which is simply a form with a button. When the button is pressed, the runner's time is calculated (the race start time is also in a session variable) and the details stored in to the underlying database (MySQL). The user is then immediately redirected back to the view/form ready for the next runner.
The controller extends the default CI_Controller class.
Here's the controller method to display the form:
Code:
public function finish(){
$this->load->helper('url');
$this->load->helper('form');
$race = new Race_model();
$data['title'] = $this->session->userdata('race_name');
$data['start'] = $this->session->userdata('race_start');
$data['finishers'] = $this->session->userdata('race_position');
$data['count'] = $this->session->userdata('runner_count');
$data['subject'] = 'finish';
$this->load->view('templates/header', $data);
$this->load->view('templates/menu', $data);
$this->load->view('races-finish.php', $data);
$this->load->view('templates/footer', $data);
}
And here's the form handler:
Code:
public function store_finish(){
$this->load->helper('url');
$dest = base_url('races/finish');
$result = new Result_model();
$race_pos = $this->session->userdata('race_position');
$data['race_id'] = $this->session->userdata('race_id');
$data['race_position'] = $race_pos;
$data['finish_time'] = time() - $this->session->userdata('race_start');
$result->add_result($data);
$this->session->set_userdata('race_position', ($race_pos + 1));
// Move the user back ready for the next finisher.
redirect($dest);
}
The add_result method is:
Code:
public function add_result($data){
$result = new Result();
$result->race_id = $data['race_id'];
$result->race_position = $data['race_position'];
$result->finish_time = $data['finish_time'];
return $result->save();
}
The person who is using the system has reported that at some point, usually after around 50 - 60 runners being logged, the screen hangs and becomes unresponsive.
Other than those variables that I've needed to change to match my system (database name, password, etc) all config variables are the default values.
Any clues as to what I should be looking at in order to fix this? I'll try and get some logs later today after I get back from work to see if they show anything.