这是我在models/action_model.php
文件夹中的codeigniter中的代码。其结果是正确的输出,但具有
error A PHP Error was encountered Severity: 4096
Message: Object of class CI_DB_mysql_driver could not be converted to string
Filename: models/action_model.php .Error found in line =3 ,line=8,13
控制器功能。
public function search_prof($community="",$gender="",$religion="",$country=""){
if($community !=""){
$where = $this->db->where ( 'userprofile.Community', $community, true);
}else{
$where.="";
}
if($gender !=""){
$where .= $this->db->where ( 'userprofile.Gender', $gender, true);
}else{
$where.="";
}
if($religion!=""){
$where .= $this->db->where ( 'religionlist.Religion_Id', $religion, true);
}else{
$where.="";
}
$this->db->select('userprofile.Name,religionlist.Religion_Name,countrylist.Country_Name,userprofile.ProfilePic');
$this->db->from('userprofile');
$this->db->join('religionlist', 'userprofile.Religion = religionlist.Religion_Id');
$this->db->join('countrylist', 'userprofile.Country = countrylist.Country_Id');
$where;
$query = $this->db->get();
if($query->num_rows() ==''){
return 'failure';
}else{
return $query->result();
}
}
->where()
不返回字符串。您应该像使用get()
一样使用它。
修正功能:
public function search_prof($community="",$gender="",$religion="",$country="")
{
if($community !="")
$this->db->where('userprofile.Community', $community, true);
if($gender !="")
$this->db->where('userprofile.Gender', $gender, true);
if($religion!="")
$this->db->where('religionlist.Religion_Id', $religion, true);
$this->db->select('userprofile.Name,religionlist.Religion_Name,countrylist.Country_Name,userprofile.ProfilePic');
$this->db->from('userprofile');
$this->db->join('religionlist', 'userprofile.Religion = religionlist.Religion_Id');
$this->db->join('countrylist', 'userprofile.Country = countrylist.Country_Id');
$query = $this->db->get();
return $query->result(); //If no results, it returns false.
}