-
☆ A M B ☆
- 279 Posts
Hi all,
I have some weird issue going on with the $modx->getCount() function. I use this inside my components processor to tell Ext how many results there are to let him create enough pages. But for some reason when I use innerJoin (or leftJoin) in my query the total is always set to 1 instead of the actual total (I expect to have 3500+ records).
When I run the query directly in my database I will get the results. Either the processor haves the 20 first results (because I have a LIMIT 0,20) but only the total number of rows are not good.
Does anyone know how this works? Thanks in advance!
[ed. note: bertoost last edited this post 14 years, 11 months ago.]
-
MODX Staff
- 10,725 Posts
You should provide the code for reference...
-
MODX Staff
- 10,725 Posts
First, you can't use groupby with limit/offset, nor is that a legal groupby for most database engines or for working with objects via getObject/getCollection/etc. Apply any grouping, sorting, limiting, etc. after the getCount().
-
☆ A M B ☆
- 279 Posts
Hmm okay, but when I run the query directly in the database it works fine! So this isn't a query issue...
And beside that; when I do the groupby after the getCount() I count 4 records of one relation, because the relation has 4 addresses (for example). And then the result total isn't right also because after the groupby there are less results
-
☆ A M B ☆
- 279 Posts
Solved thanks to Jeroen Kenters.. I'm now doing a select DISTINCT on the Relation.id field and leave the groupby out! That works great!