public function collectData(IdentifiableInterface $root) { $routes = $this->conn->fetchAll('SELECT `routeAscent` ' . 'FROM `' . EdkTables::ROUTE_TBL . '` r ' . 'INNER JOIN `' . CoreTables::AREA_TBL . '` a ON r.`areaId` = a.`id` ' . 'WHERE a.`projectId` = :projectId AND r.`routeType` = 0', [':projectId' => $root->getId()]); if (sizeof($routes) == 0) { return false; } foreach ($routes as &$row) { $row['normalized'] = $this->step($row['routeAscent']); } $this->data = []; $min = 10000; $max = 0; foreach ($routes as $row) { if ($row['normalized'] < $min) { $min = $row['normalized']; } if ($row['normalized'] > $max) { $max = $row['normalized']; } } if ($min >= $max) { return false; } for ($i = $min; $i <= $max; $i++) { $this->data[$i] = 0; } foreach ($routes as $row) { $this->data[$row['normalized']]++; } return true; }
public function collectData(IdentifiableInterface $root) { $statuses = $this->conn->fetchAll('SELECT `id`, `name` FROM `' . CoreTables::AREA_STATUS_TBL . '` WHERE `projectId` = :projectId ORDER BY `name`', [':projectId' => $root->getId()]); if (sizeof($statuses) == 0) { return false; } $ids = []; $map = []; $i = 0; foreach ($statuses as &$status) { $status['count'] = 0; $ids[] = $status['id']; $map[$status['id']] = $i++; } $counts = $this->conn->fetchAll('SELECT `statusId`, COUNT(`id`) AS `cnt` FROM `' . CoreTables::AREA_TBL . '` WHERE `statusId` IN(' . implode(',', $ids) . ') GROUP BY `statusId`'); foreach ($counts as $count) { $statuses[$map[$count['statusId']]]['count'] = $count['cnt']; } $this->data = $statuses; return true; }
/** * Checks whether the two identifiable objects are the same in terms of their unique ID-s. The method * correctly handles NULL instances, and is recommended to use. * * @param IdentifiableInterface $a * @param IdentifiableInterface $b * @return boolean */ public static function same(IdentifiableInterface $a = null, IdentifiableInterface $b = null) { if ($a === null && $b === null) { return true; } elseif ($a === null && $b !== null) { return false; } elseif ($a !== null && $b === null) { return false; } return $a->getId() == $b->getId(); }