Welcome Guest, Not a member yet? Register   Sign In
Datamapper pagination: total rows and current rows
#1

[eluser]Wazzu[/eluser]
Hi all, I-m having troubles using DMZ pagination.
I have 15 records and want to show 10 records per page.
As you can see below, I make use of $o=>count to check how many records I have found
Later I want to narrow that search so I can get just some of them, so I call $o->limit(10, $page)->get() but in this case, all my previous wheres and likes are gone.

How can I get the total number of rows within the filter and then paginate them using the same query parameters?

Code:
// User list
$o = new User();
$o->where('group_id', '3');
        
// filter
if($this->input->post('search')) {
    foreach($this->input->post('searchkey') as $key=>$value) {
        $o->like($key, $value);
        $searchkey[$key] = $value;
    }
}

// users found
$num = $o->count();

// If users found
if($num) {
    // Pagination
    $o->limit(10, $page)->get();
    $this->load->library('pagination');
    $this->pagination->initialize($config);
}


Messages In This Thread
Datamapper pagination: total rows and current rows - by El Forum - 02-22-2010, 11:48 AM
Datamapper pagination: total rows and current rows - by El Forum - 02-22-2010, 01:28 PM
Datamapper pagination: total rows and current rows - by El Forum - 02-22-2010, 01:33 PM
Datamapper pagination: total rows and current rows - by El Forum - 02-23-2010, 01:07 AM



Theme © iAndrew 2016 - Forum software by © MyBB