我不想被要求已經被回答的問題,但是我已經做了一噸的研究,我堅持。任何幫助,將不勝感激。致命錯誤:調用未定義的函數錯誤
我試圖查詢和數據庫的結果添加到Opencart的的addproduct.tpl
在MODEL文件我有:
public function units() { //function that gets database info and returns it
$unit_variables = $this->db->query("SELECT unit FROM ". DB_PREFIX ."
weight_class_description");
if (!$unit_variables) {
die(mysql_error());
}
else {
foreach ($unit_variables->rows as $temp_var) {
print_r($temp_var['unit'], true);
}
}
}
在CONTROLLER文件我有:
$this->load->model('catalog/product'); //where my function is located
$this->model_catalog_product->units();
$weight_variables = units();
if (isset($this->request->post['weight_variables'])){
$this->data['weight_variables'] = $this->request->post['weight_variables'];
}
在查看我有:
<?php echo $weight_variables ?>
我收到以下錯誤:
Call to undefined function units() in /path/to/controller/file on line etc.
注:當我的,而不是在控制器返回print_R($temp_var, true)
和刪除的代碼$weight_variables = units(); if (isset($this->request->post['weight_variables'])){ $this->data['weight_variables'] = $this->request->post['weight_variables'] }
這些行提交我的模型文件將顯示在查詢結果print_r($temp_var);
addproduct.tpl
你的班級叫什麼? – 2014-08-28 16:06:05
類ModelCatalogProduct擴展型號 – Kris 2014-08-28 16:27:15