public function sum($field)
    {
        // prepare new query
        $q = $this->dsql()->del('fields')->del('order');

        // put field in array if it's not already
        if (!is_array($field)) {
            $field = array($field);
        }

        // add all fields to query
        foreach ($field as $f) {
            if (!is_object($f)) {
                $f = $this->getElement($f);
            }
            $q->field($q->sum($f), $f->short_name);
        }

        // return query
        return $q;
    }
public function sum($field)
    {
        // prepare new query
        $q = $this->dsql()->del('fields')->del('order');

        // put field in array if it's not already
        if (!is_array($field)) {
            $field = array($field);
        }

        // add all fields to query
        foreach ($field as $f) {
            if (!is_object($f)) {
                $f = $this->getElement($f);
            }
            $q->field($q->sum($f), $f->short_name);
        }

        // return query
        return $q;
    }
public function sum ( $ field ) { // prepare new query $ q = $ this -> dsql ( ) -> del ( 'fields' ) -> del ( 'order' ) ; // put field in array if it's not already if ( ! is_array ( $ field ) ) { $ field = array ( $ field ) ; } // add all fields to query foreach ( $ field as $ f ) { if ( ! is_object ( $ f ) ) { $ f = $ this -> getElement ( $ f ) ; } $ q -> field ( $ q -> sum ( $ f ) , $ f -> short_name ) ; } // return query return $ q ; }
Returns dynamic query selecting sum of particular field or fields.

@param string|array|Field $field

@return DB_dsql
Returns dynamic query selecting sum of particular field or fields .