Class Misago\ActiveRecord\Calculations

Computes data.

Inheritence

Extends:
Validations

Methods

Public static methods

average($column, $options=array())

calculate($operation, $column='*', $options=array())

Generic calculation method.

Use whatever mathematic SQL function. For count, average, sum, minimum and maximum, use the optimized methods instead.

It returns a single float/integer if no group option is present. otherwise returns a column => value pair hash.

Options:

  • select
  • distinct

count()

Counts rows.

People::count()
People::count('date')
People::count(array('conditions' => 'age = 26'))
People::count('id', array('conditions' => 'age = 26')) 

Returned value is always is an integer.

maximum($column, $options=array())

minimum($column, $options=array())

sum($column, $options=array())