2014-11-04 61 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假定该运算符的左侧是一个对象。

相关问题