|
这是模型
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);
|
|