我的数据库中有四个表,分别为“ user_login”,“ store”,“ admin”,“ store_product”。当我尝试从user_login表中获取数据时,它不起作用。 我的代码如下:
查看表单:
<form method="get">
Enter city: <input type ="text" name="city">
Enter search keyword: <input type="text" name="searchB">
<button type="submit"> Submit </button>
</form>
控制器:
public function search()
{
$this->load->model('searchmodel');
$fc = $this->input->get('city');
$sb = $this->input->get('searchB');
$rr=$this->searchmodel->searchDetail($sb,$fc);
$data['results'] = $rr;
$this->load->view('search/detailResults',$data);
}
型号
public function searchDetail($data,$datacity){
$this->db->select();
$this->db->from('user_login');
$this->db->join('store', 'store.vendor_bri = user_login.bri', 'full outer');
$this->db->join('admin', 'admin.bri = user_login.bri', 'full outer');
$this->db->join('store_product', 'store_product.vendor_bri = user_login.bri', 'full outer');
$this->db->having('store.town', $datacity);
$this->db->or_having('store.country', $datacity);
$this->db->like('user_login.business_name',$data, 'both');
$this->db->or_like('user_login.business_type', $data);
$this->db->or_like('user_login.speciality', $data);
$this->db->or_like('store.locality', $data);
$this->db->or_like('store.vendor_bri', $data,'none');
$this->db->or_like('store_product.pd_universal_code', $data,'none');
$this->db->or_like('store_product.pd_name', $data);
$this->db->or_like('store_product.pd_description', $data);
$query = $this->db->get();
return $query->result_array();
}