| @@ 452-459 (lines=8) @@ | ||
| 449 | * automatically so must not contain double quotes. |
|
| 450 | * @return string |
|
| 451 | */ |
|
| 452 | public function max($field) |
|
| 453 | { |
|
| 454 | $table = DataObject::getSchema()->tableForField($this->dataClass, $field); |
|
| 455 | if (!$table) { |
|
| 456 | return $this->aggregate("MAX(\"$field\")"); |
|
| 457 | } |
|
| 458 | return $this->aggregate("MAX(\"$table\".\"$field\")"); |
|
| 459 | } |
|
| 460 | ||
| 461 | /** |
|
| 462 | * Return the minimum value of the given field in this DataList |
|
| @@ 468-475 (lines=8) @@ | ||
| 465 | * automatically so must not contain double quotes. |
|
| 466 | * @return string |
|
| 467 | */ |
|
| 468 | public function min($field) |
|
| 469 | { |
|
| 470 | $table = DataObject::getSchema()->tableForField($this->dataClass, $field); |
|
| 471 | if (!$table) { |
|
| 472 | return $this->aggregate("MIN(\"$field\")"); |
|
| 473 | } |
|
| 474 | return $this->aggregate("MIN(\"$table\".\"$field\")"); |
|
| 475 | } |
|
| 476 | ||
| 477 | /** |
|
| 478 | * Return the average value of the given field in this DataList |
|
| @@ 484-491 (lines=8) @@ | ||
| 481 | * automatically so must not contain double quotes. |
|
| 482 | * @return string |
|
| 483 | */ |
|
| 484 | public function avg($field) |
|
| 485 | { |
|
| 486 | $table = DataObject::getSchema()->tableForField($this->dataClass, $field); |
|
| 487 | if (!$table) { |
|
| 488 | return $this->aggregate("AVG(\"$field\")"); |
|
| 489 | } |
|
| 490 | return $this->aggregate("AVG(\"$table\".\"$field\")"); |
|
| 491 | } |
|
| 492 | ||
| 493 | /** |
|
| 494 | * Return the sum of the values of the given field in this DataList |
|
| @@ 500-507 (lines=8) @@ | ||
| 497 | * automatically so must not contain double quotes. |
|
| 498 | * @return string |
|
| 499 | */ |
|
| 500 | public function sum($field) |
|
| 501 | { |
|
| 502 | $table = DataObject::getSchema()->tableForField($this->dataClass, $field); |
|
| 503 | if (!$table) { |
|
| 504 | return $this->aggregate("SUM(\"$field\")"); |
|
| 505 | } |
|
| 506 | return $this->aggregate("SUM(\"$table\".\"$field\")"); |
|
| 507 | } |
|
| 508 | ||
| 509 | /** |
|
| 510 | * Runs a raw aggregate expression. Please handle escaping yourself |
|