調用模型函數,如下
我很是遵循錯誤
致命錯誤(!):調用未定義的方法Agentie_model :: get_agentii_list()在C:\瓦帕\ ...控制器\上線fk_controller.php 65無法從我有我的代碼問題控制器
控制器:fk_controller
public function __construct() {
parent::__construct();
$this->load->model('agentie_model');
$this->load->model('fk_model');
}
public function add2() {
$this->load->model('agentie_model');
$data['principal'] = $this->agentie_model->get_agentii_list(); //Here is the error(line 65)
$this->load->view('lista_agentii', $data);
}
型號:agentie_model
private $_table = "agentii";
public function get_agentii_list() {
$query = $this->db->get($this->_table);
return $query->result();
}
查看:lista_agentii
echo "Lista agentii:</br>";
foreach($principal as $list) {
echo $list->nume_agentie;
}
它顯示的信息:(! )致命錯誤:調用未定義的方法在第65行的C:\ wamp \ www \ fk_test \ application \ controllers \ fk_controller.php中創建Agentie_model :: get_agentii_list() –
將您的文件名重命名爲'Fk_controller.php'和模型文件名Agentie_model .php http://www.codeigniter.com/user_guide/general/styleguide.html#file-naming – user4419336