Add getCount() function to activerecord class