我是新来的笨。可有人请告诉如何在模型控制器通过$row['main_products_cat_id'];
到'id'=> 'my id here',
帮助我。我尝试了很多方法,但是失败了。笨将数据传递给控制器
谢谢!
这是我的模型
function cart_product_records($id){
$this->db->from('tbl_sub_products');
$this->db->where('tbl_sub_products.sub_product_id', $id);
$query = $this->db->get();
foreach ($query->result_array() as $row){
echo $row['main_products_cat_id'];
echo $row['sub_product_id'];
echo $row['sub_product_name'];
echo $row['sub_product_description'];
echo $row['sub_product_image'];
echo $row['sub_product_price'];
}
return $query->result();
}
这是我的控制器
function shopping_cart(){
$id = $this->input->get('id');
if($query = $this->mod_products->cart_product_records($id)){
$data['result'] = array(
'id' => 'my id here',
'qty' => my qty here,
'price' => my price here,
'name' => 'my product name here'
);
}
}
访问我认为这会是'$ query [0] - > main_products_cat_id' – Dan
你是对的。我会从模型中返回$ query [0]。 – Craig