简体   繁体   中英

How do I count the number of rows returned?

I'm using My_model (developed by jamierumbelow) for my small application.

I've got a basic user search and I'm trying to paginate the results but I can't figure out how to get the total number of rows returned by the result. This is the code I have in my controller:

protected function get_users(){


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


$this->data["users"]  = $this->user_model;

if($this->input->post('country')){
    $this->data["users"] = $this->data["users"]->search('country', $this->input->post('country'));
}

if($this->input->post('city')){
    $this->data["users"] = $this->data["users"]->search('city', $this->input->post('city'));
}


if($this->input->post('forename')){
    $this->data["users"] = $this->data["users"]->search('forename', $this->input->post('forename'));
}


if($this->input->post('surname')){
    $this->data["users"] = $this->data["users"]->search('surname', $this->input->post('surname'));
}

$this->data["bla"]  = $this->data["users"]->get_all();

}

How do I figure out the total number of results? Thanks.

使用$this->data["users"]->count_all()进行行计数。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM