Объект класса не может быть преобразован в строку класса CI_DB_mysqli_result - PullRequest
1 голос
/ 20 сентября 2019

Контроллер:

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(); 
     }
    }

Я не могу понять, как решить эту ошибку.Пожалуйста, помогите мне в этом вопросе.Я новичок в КИ.

1 Ответ

0 голосов
/ 20 сентября 2019

Запрос, который получает $item_id, неверен.Это должно быть изменено следующим образом

$item_id  =$this->db->query('select id from  item where slug='.$item);
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...