I want to update a query in my index function whenever it open so that i count number of visitor in blog or book in id pages. Here is the simple code which i have written in index function but it increments the value by 10-20 number(not fixed) when ever i refresh the page. I have tried Everything, Debug kit also shows that query is correct. Now i found out it is creating problem because of Inflector::slug('title'), which i have used in url. Please suggest a proper solution.
public function index($id)
{
$student = TableRegistry::get('count');
$queryy = $student->query();
$queryy->update()->set(['temp = temp + 1'])->WHERE(['visitor'=>$id])->execute();
}