| @@ 284-317 (lines=34) @@ | ||
| 281 | * get aggregation row | |
| 282 | * @return array | |
| 283 | */ | |
| 284 | public function getAggregationData() | |
| 285 | 	{ | |
| 286 | $result = []; | |
| 287 | 		foreach ($this->data_source as $row) { | |
| 288 | 			foreach ($this->aggregations as $column => $aggregation_type) { | |
| 289 | 				switch ($aggregation_type) { | |
| 290 | case ColumnAggregationFunction::$aggregation_type_sum: | |
| 291 | case ColumnAggregationFunction::$aggregation_type_avg: | |
| 292 | 						if (!isset($result[$column])) { | |
| 293 | $result[$column] = 0; | |
| 294 | } | |
| 295 | $result[$column] += $row[$column]; | |
| 296 | break; | |
| 297 | case ColumnAggregationFunction::$aggregation_type_min: | |
| 298 | 						if (!isset($result[$column]) || $row[$column] < $result[$column]) { | |
| 299 | $result[$column] = $row[$column]; | |
| 300 | } | |
| 301 | break; | |
| 302 | case ColumnAggregationFunction::$aggregation_type_max: | |
| 303 | 						if (!isset($result[$column]) || $row[$column] > $result[$column]) { | |
| 304 | $result[$column] = $row[$column]; | |
| 305 | } | |
| 306 | break; | |
| 307 | } | |
| 308 | } | |
| 309 | } | |
| 310 | ||
| 311 | 		foreach ($this->aggregations as $column => $aggregation_type) { | |
| 312 | 			if ($aggregation_type == ColumnAggregationFunction::$aggregation_type_avg) { | |
| 313 | $result[$column] = $result[$column] / $this->data_source->count(); | |
| 314 | } | |
| 315 | } | |
| 316 | return $result; | |
| 317 | } | |
| 318 | } | |
| 319 | ||
| @@ 395-428 (lines=34) @@ | ||
| 392 | * get aggregation row | |
| 393 | * @return array | |
| 394 | */ | |
| 395 | public function getAggregationData() | |
| 396 | 	{ | |
| 397 | $result = []; | |
| 398 | 		foreach ($this->data as $row) { | |
| 399 | 			foreach ($this->aggregations as $column => $aggregation_type) { | |
| 400 | 				switch ($aggregation_type) { | |
| 401 | case ColumnAggregationFunction::$aggregation_type_sum: | |
| 402 | case ColumnAggregationFunction::$aggregation_type_avg: | |
| 403 | 						if (!isset($result[$column])) { | |
| 404 | $result[$column] = 0; | |
| 405 | } | |
| 406 | $result[$column] += $row[$column]; | |
| 407 | break; | |
| 408 | case ColumnAggregationFunction::$aggregation_type_min: | |
| 409 | 						if (!isset($result[$column]) || $row[$column] < $result[$column]) { | |
| 410 | $result[$column] = $row[$column]; | |
| 411 | } | |
| 412 | break; | |
| 413 | case ColumnAggregationFunction::$aggregation_type_max: | |
| 414 | 						if (!isset($result[$column]) || $row[$column] > $result[$column]) { | |
| 415 | $result[$column] = $row[$column]; | |
| 416 | } | |
| 417 | break; | |
| 418 | } | |
| 419 | } | |
| 420 | } | |
| 421 | ||
| 422 | 		foreach ($this->aggregations as $column => $aggregation_type) { | |
| 423 | 			if ($aggregation_type == ColumnAggregationFunction::$aggregation_type_avg) { | |
| 424 | $result[$column] = $result[$column] / count($this->data); | |
| 425 | } | |
| 426 | } | |
| 427 | return $result; | |
| 428 | } | |
| 429 | } | |
| 430 | ||