/** * Get locomotive data as an associative array * @since Version 3.9 * @return array */ public function getArray() { return array("id" => $this->id, "number" => $this->number, "name" => $this->name, "gauge" => $this->gauge, "status" => array("id" => $this->status_id, "text" => strval(new Status($this->status_id))), "manufacturer" => array("id" => $this->manufacturer_id, "text" => $this->manufacturer), "class" => $this->Class->getArray(), "url" => $this->url->getURLs()); }
/** * Get locomotive classes built by this manufacturer * @return array */ public function getClasses() { $query = "SELECT id, name, loco_type_id, introduced AS year_introduced, manufacturer_id, wheel_arrangement_id FROM loco_class WHERE manufacturer_id = ? OR id IN (SELECT class_id FROM loco_unit WHERE manufacturer_id = ?) GROUP BY id ORDER BY name"; $return = array(); foreach ($this->db->fetchAll($query, array($this->id, $this->id)) as $row) { $LocoClass = new LocoClass($row['id']); $return[] = $LocoClass->getArray(); } return $return; }
/** * Get locomotive classes by this type * @return array */ public function getClasses() { $query = "SELECT id FROM loco_class WHERE loco_type_id = ? ORDER BY name"; $return = array(); foreach ($this->db->fetchAll($query, $this->id) as $row) { $LocoClass = new LocoClass($row['id']); $return[] = $LocoClass->getArray(); } return $return; }