Welcome Guest, Not a member yet? Register   Sign In
Paginating with Active Record - Possible *mistake* in CI2 User Guide
#1

[eluser]stormbytes[/eluser]
I spent a good few hours debugging this last night...

The Ci2 UG states:
Code:
$query = $this->db->get('mytable', 10, 20);

// Produces: SELECT * FROM mytable LIMIT 20, 10 (in MySQL. Other databases have slightly different syntax)

The above implies the following format:

Code:
$query = $this->db->get('mytable', $offset, $limit);

Unless I'm going senile, after several hours of debugging my script it seems that the order of the 'limit' & 'offset' arguments in actually backwards!. The correct order seems to be:

Code:
$query = $this->db->get('mytable', $limit, $offset);

// Or using the User Guide's example:

$query = $this->db->get('mytable', 20, 10);

Someone please correct me/this if I misunderstood something -




Theme © iAndrew 2016 - Forum software by © MyBB