簡體   English   中英

獲取 null 值,同時在 ZE1BFD762321E409CEE4ZAC0B6E8 中將變量從 model 傳遞到 controller

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM