やあみんな、あなたが私を助けてくれることを望んでいました.
私はプロジェクトに取り組んでいて、奇妙な問題を抱えていました。
私は最初にこのコードを持っていました
public function create_visit($host_id,$type){
$ip=$this->ci->input->ip_address();
$visit=$this->ci->host_model->get_visit($host_id,$this->ci->input->ip_address());
if($visit->num_rows()>0){//already created
$date_week=new DateTime();
$date_week->modify('-1 weeks');
$visit_time=strtotime($visit->row()->create_date);
if($date_week->getTimestamp()<$visit_time){
$this->ci->input->set_cookie(COOKIE_PREFIX.'visit_id', $visit->row()->id, COOKIE_TIMEOUT);
return;
}
}
この行の直後に問題がif($date_week->getTimestamp()<$visit_time){
あり、実行されませんでした。xamp では正常に機能しましたが、クライアントサーバーでは機能しませんでした。私はたくさんのエコーを行い、最終的に犯人を見つけたので、代わりにコードをこれに変更しました
public function create_visit($host_id,$type){
$ip=$this->ci->input->ip_address();
$visit=$this->ci->host_model->get_visit($host_id,$this->ci->input->ip_address());
if($visit->num_rows()>0){//already created
$date_week=time()-604800;
$visit_time=strtotime($visit->row()->create_date);
if($date_week<$visit_time){
$this->ci->input->set_cookie(COOKIE_PREFIX.'visit_id', $visit->row()->id, COOKIE_TIMEOUT);
return;
}
}
現在は機能しています(前述の変更のみ)が、問題が何であったかを本当に理解したい..それが役立つ場合は、hmvcプラグインでcodeigniterを使用しています...