[eluser]Unknown[/eluser]
The following is a partial code of my program. It count the page view.
But, it seem like the method was executed twice.
So, the count view were 0, 2, 4, 6, 8, 10 ... and so on
Code:
class Blog extends Controller{
function Blog(){
parent::Controller();
}
function view($id=-1){
$this->load->database();
$result = mysql_query("UPDATE mytable SET num_view = num_view + 1 WHERE id = '$id'");
}
}
When i remove the sql statement. the counter do nothing. So, it means that the method was executed twice. Is it a bug of the CI.
Sorry, I found the problem. It came from the url that can mislead to execute the function twice.