php调用成员函数错误,php – 致命错误:调用成员函数

在尝试使用CodeIgniter PHP框架显示数据库表内容时遇到错误。具体表现为在控制器'users.php'中调用模型'Users'的'getUsersWhere'方法时,出现'Call to a member function getUsersWhere() on non-object'的致命错误。问题可能出在模型加载或者实例化上。
摘要由CSDN通过智能技术生成

我需要帮助调试我的代码.我是新的

PHP和我目前正在使用codeigniter框架.我试图将我的数据库表的内容显示到我的页面

/controllers/users.php

$<?php

class Users extends CI_Controller{

function __Users(){

// load controller parent

parent::__Controller();

// load 'Users' model

$this->load->model('Users');

}

function index(){

$data['users']=$this->Users->getUsersWhere('userid

$data['numusers']=$this->Users->getNumUsers();

$data['title']='Displaying user data';

$data['header']='User List';

// load 'users_view' view

$this->load->view('users_view',$data);

}

}

?>

/models/users.php

$<?php

class Users extends CI_Model{

function __Users(){

// call the Model constructor

parent::__CI_Model();

// load database class and connect to MySQL

$this->load->database();

}

function getAllUsers(){

$query=$this->db->get('admin_user');

if($query->num_rows()>0){

// return result set as an associative array

return $query->result_array();

}

}

function getUsersWhere($field,$param){

$this->db->where($field,$param);

$query=$this->db->get('admin_user');

// return result set as an associative array

return $query->result_array();

}

// get total number of users

function getNumUsers(){

return $this->db->count_all('admin_user');

}

}

?>

我有这个错误

Fatal error: Call to a member function

getUsersWhere() on a non-object in

C:\xampp\htdocs\printone\application\controllers\users.php

on line 16

可能是什么错?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值