Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/57.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php CodeIgniter-参考Url-保存在数据库中_Php_Mysql_Codeigniter_Refer - Fatal编程技术网

Php CodeIgniter-参考Url-保存在数据库中

Php CodeIgniter-参考Url-保存在数据库中,php,mysql,codeigniter,refer,Php,Mysql,Codeigniter,Refer,我需要在数据库中保存一个参考url,例如用户在facebook上看到广告,当用户来时单击链接仅在数据库中保存url为此我制作了一个函数,但我没有得到确切的函数,请建议 欢迎使用php控制器 编辑\u 1\u 将welcome.php更改为://您忘记加载user\u model $this->load->library('user_agent'); $this->load->library('user_model'); $refer_url =

我需要在数据库中保存一个参考url,例如用户在facebook上看到广告,当用户来时单击链接仅在数据库中保存url为此我制作了一个函数,但我没有得到确切的函数,请建议

欢迎使用php控制器


编辑\u 1\u

welcome.php
更改为://您忘记加载
user\u model

    $this->load->library('user_agent');
    $this->load->library('user_model');

    $refer_url =  $this->user_agent->referrer();    
    $this->user_model->refer_data($refer_url);
user\u model.php
更改为:

    $insert = $this->insert('refer', $refer_data);

你加载了用户代理库吗?它已经加载了,因为我有两个版本的网站,一个用于移动设备,一个用于桌面计算机,所以它已经加载。你从echo获得o/p吗?我在模型中添加了此函数,但没有结果,这就是为什么我问此代码是否正确或问题所在。我在模型中添加此代码并在本地服务器上测试,但没有结果加载项数据库。@正式添加到控制器,或者,如果在模型中,将
$this->db->insert
更改为
$this->insert
@FormaL如果您在本地测试,则删除
$this->agent->is_reference()
始终会返回我在控制器中提到的错误代码,并在我再次访问web时更新,无任何显示!等待,然后我将上传到int服务器并检查ok
function refer(){
   $this->load->library('user_agent');
   if ($this->agent->is_referral()) {
      $insert =$this->db->insert('refer', array('refer_url'=>$this->agent->referrer()));    
   }
}
    $this->load->library('user_agent');
    $this->load->library('user_model');

    $refer_url =  $this->user_agent->referrer();    
    $this->user_model->refer_data($refer_url);
    $insert = $this->insert('refer', $refer_data);