-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Bug: inconsistent behavior of Query Builder limit 0 #6253
Comments
This is no a bug but design. $this->db->get('table', 0) means no limit not zero records. |
No, it is not documented like that.
CodeIgniter/system/database/DB_query_builder.php Lines 1438 to 1443 in 63d0375
|
interesting. seems i misunderstood it then. I looked into DB_query_builder.php and it seems you are right. 0 should indeed be passed as a limit. Do you have the generated SQL query from your code? Just to be sure if the code is generated correctly or not? |
|
This is what I mentioned originally: 0 is not passed along due to this in the DB_query_builder.php:
giving you all records when you set limit to zero. If you change it to
It should return what you expect. But again my understanding was that 0 was supposed to be interpreted als "do not set a limit" but I might be wrong. |
No, no.
|
I know that limit 0 returns 0 records in MySQL. But I understood the CI way differently: namely limit 0 = no limit, I have no other ideas why limit is dropped. Sorry. |
It seems CI3 distinguishes between |
$this->db->limit(0)->get('table')
returns no records.But
$this->db->get('table', 0)
returns all records.Steps to reproduce:
Result:
The text was updated successfully, but these errors were encountered: