use tp5 to write a pageview function, each page refresh on + 1, offline local test is normal, put online, using the server"s browser test is also + 1, offline access online is changed to each refresh + 4, with static variable test results executed only once, exclusion code Bug, where is the problem?
attach code:
/**
*
* +1
*/
public function detail($id="",$browse=true,$sql=false)
{
if (empty($id)) goto end;
$data = $this->alias("a","left")
->field("a.id,a.tid,a.title,a.keyword,a.introduce,a.content,a.img,a.addtime,a.browse,u.name user_name,t.name type_name")
->join("tags t","t.id=a.tid","left")
->join("user u","u.id=a.uid","left")
->where(array("a.id"=>$id,"a.status"=>2))
->find();
// dp($this->getLastSql());
if (true == $sql) return $this->getLastSql();
end:
if (empty($data)) return null;
//+1
if (true == $browse) $this->where("id",$data["id"])->setInc("browse");
$data = $data->toArray();
$data["user_name"] ? : $data["user_name"] = "admin";
return $this->cotm($data);
}
this is the only operation in which the code for browsing + 1 is written
if (true = = $browse) $this- > where ("id",$data [" id"])-> setInc ("browse");
found the reason. I looked at the log and found that the program was executed four times
but why was it executed four times?