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

QB countAllResults shouldn't use LIMIT settings #2152

Closed
tangix opened this issue Aug 20, 2019 · 0 comments · Fixed by #2153
Closed

QB countAllResults shouldn't use LIMIT settings #2152

tangix opened this issue Aug 20, 2019 · 0 comments · Fixed by #2153

Comments

@tangix
Copy link
Contributor

tangix commented Aug 20, 2019

Describe the bug
When running a query and re-using the same WHERE and LIMIT settings for the countAllResults, the count will be zero is the offset parameter to get() is > 0.
For example this code will produce the wrong $total count:

$builder = db_connect()->table('users');
$builder->select('userID,firstname,lastname,email')
->where('companyLink !=', 0);
$query = $builder->get(50, 50, false, false); // Don't reset QB
$total = $builder->countAllResults($builder);

The get() is configured not to reset the QB state and thus the LIMIT 50, 50 will be in effect when running the countAllResults() query. Since LIMIT 50, 50 is in effect, the first (and only) result row of the the COUNT(*) query is lost.

CodeIgniter 4 version
4.0.0-beta4

Affected module(s)
Database\BaseBuilder

Expected behavior, and steps to reproduce if appropriate
Getting anything else than zero back.

Context
PHP 7.3.8

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

Successfully merging a pull request may close this issue.

1 participant