控制器:
function index()
{
$this->load->helper(array('form', 'url','common'));
$this->load->library(array('session','pagination'));
$this->load->model('productsdisplay','',TRUE);
$data=array(
'header' => $this->load->view('frontend/assets/header', '', TRUE),
'footer' => $this->load->view('frontend/assets/footer', '', TRUE),
);
$item= $this->input->get('products', TRUE);
$newarray[]=array();
$item_id =$this->db->query('select id from item where slug=(".$item.")');
$result=$item_id->result();
var_dump($result);
$data['category']=$this->productsdisplay->getAllCategories($item_id);
$data['kvas']=$this->productsdisplay->getAllKva();
$data['items']=$this->productsdisplay->getAllItems();
$data['applications']=$this->productsdisplay->getAllApplication();
$data['products'] = $this->productsdisplay->getAllProduct();
$data['ads'] = $this->productsdisplay->getAllAds();
$insert_id=$this->productsdisplay->addEnquiry($this->input->post());
$this->load->view('frontend/product/index',$data);
}
型号:
function getAllCategories($item_id)
{
if($item_id!=''){
$this->db->select('category_name');
$this->db->order_by("category_name", "ASC");
$query = $this->db->where('product_type',$item_id);
$query = $this->db->get('category');
return $query->result();
}
}
我无法理解如何解决此错误。请帮助我解决这个问题。 我是CI的初学者。
答案 0 :(得分:0)
获取$item_id
的查询是错误的。应该进行如下更改
$item_id =$this->db->query('select id from item where slug='.$item);