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

[3.2.x] Paginator QueryBuilder with HAVING doesn't support multiple db services #12957

Closed
dnapierata opened this issue Jul 12, 2017 · 2 comments
Labels

Comments

@dnapierata
Copy link
Contributor

dnapierata commented Jul 12, 2017

Expected and Actual Behavior

When using the paginator querybuilder with a HAVING and with a model which uses a different db connection service. The paginator incorrectly assumes that the db service is 'db' when performing a count of the total records. https://github.com/phalcon/cphalcon/blob/3.2.x/phalcon/paginator/adapter/querybuilder.zep#L227

I expect that it would use the connection service of the model that the query was built for.
Example:

let modelClass = builder->_models;
if typeof modelClass == "array" {
    let modelClass = array_values(modelClass)[0];
}
let model = new {modelClass}();
let dbService = model->getReadConnectionService();
let db = totalBuilder->getDI()->get(dbService);

Details

  • Phalcon version: (3.2.1)
  • PHP Version: (7.0.18)
  • Operating System: Ubuntu
  • Installation type: Installing via package manager
  • Server: Apache
@Jurigag
Copy link
Contributor

Jurigag commented Jul 12, 2017

Good point, can you do PR with this code to 3.2.x branch?

@sergeyklay
Copy link
Contributor

@dnapierata
I'm hope this fixed in the #12960 PR. Could you please create a small test which will cover code you have changed? Thank you for contributing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants