Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database Documentation small Error #2089

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

Database Documentation small Error #2089

codebryo opened this issue Dec 21, 2012 · 1 comment

Comments

@codebryo
Copy link

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
Copy link
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 as completed Dec 22, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants