2014-11-04 152 views
0

我試圖更新此並顯示試圖讓非對象的財產。如何解決這個任何人可以幫助我爲什麼我得到這個錯誤試圖獲得非對象的屬性?

$data['dotdprod'] = $this->Product_model->get_products($data['dotdcat']->id, '5', '0', 'sort_price', 'ASC'); 

和型號是:

function get_products($category_id = false, $limit = false, $offset = false, $by=false, $sort=false) 
{ 
    //if we are provided a category_id, then get products according to category 
    if ($category_id) 
    { 
     $this->db->select('category_products.*, products.*, LEAST(IFNULL(NULLIF(saleprice, 0), price), price) as sort_price', false)->from('category_products')->join('products', 'category_products.product_id=products.id')->where(array('category_id'=>$category_id, 'enabled'=>1)); 

     $this->db->order_by($by, $sort); 

     $result = $this->db->limit($limit)->offset($offset)->get()->result(); 

     return $result; 
    } 
    else 
    { 
     //sort by alphabetically by default 
     $this->db->order_by('name', 'ASC'); 
     $result = $this->db->get('products'); 

     return $result->result(); 
    } 
} 

回答

0

有誤差警告你你試圖訪問一個沒有屬性的東西。

當您嘗試訪問$data['dotdcat']->id時,此處假定$data['dotdcat']是一個對象。如果不是,那麼你看到的錯誤被拋出。

我不知道錯誤在哪裏引發,但在任何地方你使用箭頭運算符-> - php假定該運算符的左側是一個對象。

相關問題