我收到错误消息:
调用数组上的成员函数 num_rows()
我的控制器是
function index() {
$config=[
'base_url' => base_url('Users'),
'per_page' =>5,
'total_rows' => $this->Useraccount_mod->num_row(),
];
$this->pagination->initialize($config);
if ($this->input->post('submit') != NULL) {
$data = array();
$data['username'] = $this->input->post('username');
$data['name'] = $this->input->post('name');
$result['data'] = $this->Useraccount_mod->getUser_list($data,$config['per_page'], $this->uri->segment(2));
$data['userlist'] = $result['data'];
$this->load->view('Useraccount/Userlist', $data);
} else {
$data = array();
$result['data'] = $this->Useraccount_mod->getUser_list($data,$config['per_page'], $this->uri->segment(2));
$data['userlist'] = $result['data'];
$this->load->view('Useraccount/Userlist', $data);
}
}
模型是
function getUser_list($data, $limit, $offset) {
if ($data) {
$this->db->like('username', $data['username']);
$this->db->like('name', $data['name']);
$query = $this->db->get('users')->limit($limit, $offset)->get();
return $query->result_array();
} else {
$query = $this->db->get("users")->limit($limit, $offset)->get();
return $query->result_array();
}
}
function num_row() {
$query = $this->db->get("users");
$total_rows= $query->result_array()->num_rows();
print_r($total_rows);
return $total_rows;
}
遇到 PHP 错误 严重性:错误
消息:调用数组上的成员函数 num_rows()
文件名:models/Useraccount_mod.php
行号:41
回溯:
天涯尽头无女友
隔江千里
一只名叫tom的猫