Database Documentation small Error #2089

Closed
codebryo opened this Issue Dec 21, 2012 · 1 comment

Projects

None yet

3 participants

@codebryo

Hi there, I just stumbled over a small error in the database part of the documentation concerning the active Records. During explaining it to someone I realized you missplaced the parameters.

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

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

-->

but it should be documented as LIMIT 10, 20

@AndrewPodner
Contributor

In CI, the get parameters are: Table name, limit, offset

In Mysql when you use limit, if you use 2 values, the first is the offset and the 2nd is the number of rows:

"With two arguments, the first argument specifies the offset of the first row to return, and the second specifies the maximum number of rows to return." - MySQL

So:

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

I believe that CI puts the limit parameter first because it is the most commonly used.

Cheers

@narfbg narfbg closed this Dec 22, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment