【发布时间】:2014-06-27 15:46:26
【问题描述】:
我是 CodeIgniter 的新手。有人可以告诉我如何将模型中的 $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'
);
}
}
【问题讨论】:
标签: php codeigniter