AM尝试连接modal
中的controller
但显示错误
致命错误:在第25行的C:\ xampp \ htdocs \ CI \ application \ controllers \ Customer.php中调用未定义的函数customerslist() 遇到PHP错误
严重性:错误
消息:调用未定义的函数customerslist()
文件名:controllers / Customer.php
行号:25
回溯:
我的代码如下:
控制器:Customer.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Customer extends CI_Controller {
public function __construct(){
parent:: __construct();
$this->load->library('form_validation');
$this->load->model('admin');
$this->load->model('customers');
}
public function index()
{
if($this->session->userdata('Admin')==false)
{
redirect('login');
}
else
{
$data['title'] = "Customer";
$data['customerlist'] = $this->customers>customerslist();
$this->load->view('customer',$data);
}
}
}
模态:Customers.php
<?php
class Customers extends CI_Model {
function __construct()
{
parent::__construct();
}
//view all Customers
function customerslist()
{
$res = $this->db->get('customers_list');
if($res->num_rows() >0){
foreach($res->result_array() as $row){
$customerlist[] = $row;
}
return $customerlist;
}
else
{
return false;
}
}
//view all Customers
}
我该如何解决这个问题? 提前谢谢....
答案 0 :(得分:1)
您错过了-
$this->customers>customerslist();
这应该是$this->customers->customerslist();