请帮我插入代码在facebook和google登录用户详细信息中无法正常工作
下面是我的模型函数
#facebook插入代码..
public function checkUser($data = array()){
$this->db->select('*');
$this->db->where('id', $this->primaryKey);
$this->db->from($this->tablename);
$this->db->where(array('oauth_provider'=>$data['oauth_provider'],'oauth_uid'=>$data['oauth_uid']));
$prevQuery = $this->db->get();
$prevCheck = $prevQuery->num_rows();
if($prevCheck > 0){
$prevResult = $prevQuery->row_array();
$data['modified'] = date("Y-m-d H:i:s");
$update = $this->db->update($this->tablename,$data,array('id'=>$prevResult['id']));
$userID = $prevResult['id'];
}else{
$data['created'] = date("Y-m-d H:i:s");
$data['modified'] = date("Y-m-d H:i:s");
$insert = $this->db->insert($this->tablename,$data);
$userID = $this->db->insert_id();
}
return $userID?$userID:FALSE;
}
This function insert twice and if oauth_uid already exists then it again insert I want if exists then only update
***#google insert code..***
public function google_checkUser($data = array()){
$this->db->select($this->primaryKey);
$this->db->from($this->tablename);
$this->db->where(array('oauth_provider'=>$data['oauth_provider'],'oauth_uid'=>$data['oauth_uid']));
$prevQuery = $this->db->get();
$prevCheck = $prevQuery->num_rows();
if($prevCheck > 0){
$prevResult = $prevQuery->row_array();
$data['modified'] = date("Y-m-d H:i:s");
$update = $this->db->update($this->tablename,$data,array('id'=>$prevResult['id']));
$userID = $prevResult['id'];
}else{
$data['created'] = date("Y-m-d H:i:s");
$data['modified'] = date("Y-m-d H:i:s");
$insert = $this->db->insert($this->tablename,$data);
$userID = $this->db->insert_id();
}
return $userID?$userID:FALSE;
}
这很有效,但是当我更新电子邮件时,它会更多时间插入Facebook代码4请帮助解决此问题