我不想被要求已经被回答的问题,但是我已经做了一吨的研究,我坚持。任何帮助,将不胜感激。致命错误:调用未定义的函数错误
我试图查询和数据库的结果添加到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