Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Zend paginator dbselect count #4590

Closed

Conversation

fatmuemoo
Copy link

Fixes row count issue when you use GROUP with original query.

@ralphschindler
Copy link
Member

For changes like this, I really need to be able to test the approach on multiple databases. Can you create a generic schema with generic data that shows the usage of group and what you think the expected output should be? It would really assist me in the testing of this across multiple platforms.

@fatmuemoo
Copy link
Author

@ralphschindler I will get that to you soon

@fatmuemoo
Copy link
Author

@ralphschindler
SQL Script http://pastebin.com/NhHLxTnd

MySQL Query: http://pastebin.com/rm2amQd6

Expected output(ie pull request): 10
Actual output(ie current issue): 13

Please let me know if there is more I can do.

@ghost ghost assigned ralphschindler Jun 11, 2013
@ralphschindler
Copy link
Member

I'm working on this, but at current, it doesn't seem like COUNT(DISTINCT expr) is portable in the sense that expr can be multiple columns (like in Postgresql). The answer might lie in subselects though.

@ralphschindler
Copy link
Member

For example, this seems more portable (with your use case tables):

SELECT COUNT(1) as "the_count" FROM (
    SELECT DISTINCT u.id, p.id
    FROM transaction_line tl
    INNER JOIN transactions t ON tl.transaction_id = t.id
    INNER JOIN users u ON t.user_id = u.id
    INNER JOIN products p ON tl.product_id = p.id
) as c

@ralphschindler
Copy link
Member

Could you have a look at the solution in #4641 and let me know if it works for you?

@fatmuemoo
Copy link
Author

Yes, #4641 works! Thanks.

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

Successfully merging this pull request may close these issues.

2 participants