I want to know how to use arregate sql functions for when making a Magento module. I currently have this code inside my mode;
$rake = Mage::getModel('showdown/votes')->getCollection();
$rake->addFieldToFilter('votedfor', $productid);
//$collection->groupByFilter('matchid'); //<-- what do i put here?
$sticks = count($rake);
I’m not sure exactly what you want to achieve as the title of you question conflicts with the code example provided.
The title asks how to count a collection, and your code example asks how to perform a group by.
So,
Collection Count
count($collection),$collection->count()or simply$collection->getSize()which will avoid the collection load (ideal if you simply require the count and nothing else)Group By
EAV Based Collection:
Non EAV Based Collection: