Php 无法检索结果数据

Php 无法检索结果数据,php,codeigniter,Php,Codeigniter,我试图通过查询检索一组行。但是,当我试图检索$query->result()时,无法检索结果集 使用print\r($query),我得到以下结果: object(CI_DB_mysql_result)#22 (8) { ["conn_id"]=> resource(61) of type (mysql link persistent) ["result_id"]=> resource(82) of type (mysql result) ["result_array"

我试图通过查询检索一组行。但是,当我试图检索
$query->result()
时,无法检索结果集

使用
print\r($query)
,我得到以下结果:

object(CI_DB_mysql_result)#22 (8) {
  ["conn_id"]=> resource(61) of type (mysql link persistent) 
  ["result_id"]=> resource(82) of type (mysql result)
  ["result_array"]=> array(0) { } ["result_object"]=> array(0) { } 
  ["custom_result_object"]=> array(0) { }
  ["current_row"]=> int(0)
  ["num_rows"]=> int(8)
  ["row_data"]=> NULL
}
该表包含数据且不为空。代码中正确指定了所有参数和名称

我的代码如下:

型号:

 function site_detail( $vendor_id, $city, $restict_year, $type, $total_length, $adult, $children,$pets ) {

            $this->db->select('*');
            $this->db->from('vendor_details');

            $this->db->join('vendor_siteinfo', 'vendor_siteinfo.vendor_id = vendor_details.id', 'left');
            $this->db->join('vendorstay_details', 'vendorstay_details.vendor_id=vendor_details.id');

            $this->db->where('city',$city);
            $this->db->where('year_restrict',$restict_year);
            $this->db->where('site_type',$type);
            $this->db->where('site_length',$total_length);
            $this->db->where('adult_limit',$adult);
            $this->db->where('child_limit',$children);
            $this->db->where('pet_limit',$pets);


            $query = $this->db->get(); 
            $total=$query->num_rows();
            if($total != 0)
            {
               // echo "Search details found !!!";
              //  echo "TOTAL"; echo "$total";
                return $query->result_array();
            }
            elseif($total= 0)
            {    
                //echo "No results!";
                 return false;
            }
            print_r($query);
        }
控制器:

 function search_detail($vendor_id, $city, $restict_year, $type, $total_length, $adult, $children, $pets) {

         $data['site']=$this->Home_Model->site_detail($vendor_id,$city,$restict_year,$type,$total_length,$adult,$children,$pets);
       //   $data['site_detail']=$this->Home_Model->sample($vendor_id);
         //echo "site=$site";
            print_r($data);
            $this->load->view("search_detail",$data);

    }
视图:


要检索
$query
,您需要执行以下操作:

// for object
foreach($query->result() as $row)
{
    echo $row->your_table_field_name;
}


我也有同样的问题和你的建议

$result = $this->db->get()->result_array();
为我工作。 但我很好奇,为什么我的原始代码突然停止工作,所有的变化都是我的服务器

$this->db->select('*');
$this->db->from('isl_user');
$this->db->order_by('isl_user.name','asc');
$query = $this->db->get();
return $query;

你能提供完整的代码(包括查询本身)吗?
$result = $this->db->get()->result_array();
$this->db->select('*');
$this->db->from('isl_user');
$this->db->order_by('isl_user.name','asc');
$query = $this->db->get();
return $query;