用户
 找回密码
 入住 CI 中国社区
搜索
查看: 3411|回复: 1
收起左侧

[已解决] Trying to get property of non-object

[复制链接]
发表于 2012-3-6 08:42:08 | 显示全部楼层 |阅读模式
这是模型

function get_cart($id)
        {
                $q=$this->db->get_where('product',array('id'=>$id));
                if($q->num_rows()>0)
                {
                foreach ($q->result()as $results)
                {
                       
                       
                $cart[]=$results;
                }
                        return $cart;
                }
               
        }
这是控制器
   function add ()     {              $cart = $this->Products_model->get_cart($this->input->post('id'));     $data = array         (  'id' => $this->input->post('id'),     'qty' => $this->input->post('qty') ,     'qty2' => $this->input->post('qty2'),    'price' => $cart->price,        'name' => $cart->brand     );     $c=$this->cart->insert('data');

Message: Trying to get property of non-objectFilename: controllers/cart.phpLine Number: 34
             echo print_r($c);

发表于 2012-3-6 10:07:52 | 显示全部楼层
兄弟 你忘记了这一句啊
$this->load->library('cart');

本版积分规则