$query=$this->db->query("SELECT ".TABLE_USER.".username, ".TABLE_USER.".uid, ".TABLE_USER.".realname, ".TABLE_USER.".dn, ".TABLE_USER.".password, ".TABLE_USER.".isadmin, ".TABLE_USER.".domain FROM ".TABLE_USER.", ".TABLE_EMAIL." WHERE ".TABLE_EMAIL.".email=? AND ".TABLE_EMAIL.".uid=".TABLE_USER.".uid",array($google_account['email']));
$query=$this->db->query("SELECT email FROM ".TABLE_GOOGLE." WHERE email=?",array($email));
if($query->num_rows>0){
$query=$this->db->query("UPDATE ".TABLE_GOOGLE." SET id=?, access_token=?, refresh_token=?, created=? WHERE email=?",array($id,$token->{'access_token'},$token->{'refresh_token'},$token->{'created'},$email));
}
else{
$query=$this->db->query("INSERT INTO ".TABLE_GOOGLE." (id, email, access_token, refresh_token, created) VALUES(?,?,?,?,?)",array($id,$email,$token->{'access_token'},$token->{'refresh_token'},$token->{'created'}));