original_string: 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;
      }
code: 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;
      }
code_tokens: 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 ; }
docstring: Returns dynamic query selecting sum of particular field or fields.
  
  @param string|array|Field $field
  
  @return DB_dsql
docstring_tokens: Returns dynamic query selecting sum of particular field or fields .