Fix xPDO::getCount() to work with queries containing group by

Closes modxcms/revolution#513