[英]Getting Null Value when passing variables from controller to model in codeigniter
[英]getting null value while passing varaible from model to controller in php
获取 null 值,同时将变量从 model 传递到 Z2FEC392304A5C23AC138DA228CZ4 中的 Z2FEC392304A5C23AC138DA228C7 中的 controller 值。 实际上我无法将数量从 model 传递到 controller。
model ->
public function getcomboProduct ($product_id) {
$combo_product_data = array();
$query = $this->db->query("Select bundled_id,qty FROM " . DB_PREFIX . "product_bundle where
product_id=" . $product_id . "");
foreach ($query->rows as $result) {
$combo_product_data[$result['bundled_id']] = $this->getProduct($result['bundled_id']);
$combo_product_data[$result['quantity']] = $result['qty'];
}
return $combo_product_data;
}
controller ->
$results = $this->model_catalog_product->getcomboProduct($product_id);
foreach ($results as $result) {
$data['comboproducts'][] = array(
'product_id' => $result['product_id'],
'thumb' => $image,
'quantity' => $result['quantity'],
'name' => $result['name'],
'price' => $price,
'href' => $this->url->link('product/product', 'product_id=' . $result['product_id'])
);
}
我认为您在 sql 查询中犯了语法错误,因此您需要放置“.$product_id”。 像 '".$product_id."' 这样的单引号如下
$query=$this->db->query("Select bundled_id,qty FROM " . DB_PREFIX ."product_bundle where product_id='".$product_id."'");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.