We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37286
    • 160 Posts
    Found something odd and I'm not sure if it's a bug or if I'm doing something wrong. When I try to do a groupby and use the getCount function, I get a result of 1. I know that this value is wrong as further down I execute the query to display the data and I get the 50 or so results I expect. My code looks something like:
    $c->groupby('field');
    $count= $modx->getCount('table',$c); // returns 1
    // ... I have my sortby's and limit here, commented out while I troubleshoot
    $listItems= $modx->getCollection('table',$c); // returns 50
    


    Reversing the order of the groupby and the getCount returns a count, but the groupby is needed to get the correct count. Is there another way to do this?