AM 尝试在controller
中连接modal
,但它显示错误,例如
致命错误:在第 25 行调用 C:\xampp\htdocs\CI\application\controllers\Customer.php 中的未定义函数 customerslist(( 遇到 PHP 错误
严重性:错误
消息:调用未定义的函数 customerslist((
文件名:控制器/客户.php
行号:25
回溯:
我的代码如下:
控制器:客户.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);
}
}
}
模态:客户.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
}
如何解决此问题? 提前谢谢....
您在$this->customers>customerslist();
中缺少-
这应该是$this->customers->customerslist();