/** * Constructor * @since Version 3.9 * @param int $id */ public function __construct($id = false) { parent::__construct(); if (is_string($id)) { $query = "SELECT id FROM timetable_points WHERE name = ? OR slug = ?"; if ($tmpid = $this->db->fetchOne($query, array($id, $id))) { $id = $tmpid; } else { $this->name = $id; $this->commit(); } } if (filter_var($id, FILTER_VALIDATE_INT)) { $this->mckey = sprintf("railpage:timetable.point=%d", $id); if (!($row = getMemcacheObject($this->mckey))) { $query = "SELECT * FROM timetable_points WHERE id = ?"; $row = $this->db->fetchRow($query, $id); setMemcacheObject($this->mckey, $row); } } if (isset($row) && count($row)) { $this->id = $row['id']; $this->lat = $row['lat']; $this->lon = $row['lon']; $this->name = $row['name']; $this->slug = isset($row['slug']) ? $row['slug'] : ""; if (!isset($row['slug']) || empty($row['slug']) || substr($row['slug'], -1, 1) == "1") { $this->createSlug(); $this->commit(); } $this->url = new Url(sprintf("%s/p/%s", $this->Module->url, $this->slug)); $this->url->edit = sprintf("%s?mode=point.edit", $this->url->url); } }
/** * Constructor * @since Version 3.9 */ public function __construct($id = false, $provider = false) { parent::__construct(); if ($id != false && $provider == "artc") { $query = "SELECT id FROM timetable_trains WHERE train_number LIKE ? AND provider = ?"; $id = $this->db->fetchOne($query, array("%" . $id . "%", $provider)); } if (filter_var($id, FILTER_VALIDATE_INT)) { $this->mckey = sprintf("railpage:timetable.train=%d", $id); if (!($row = getMemcacheObject($this->mckey))) { $query = "SELECT * FROM timetable_trains WHERE id = ?"; $row = $this->db->fetchRow($query, $id); setMemcacheObject($this->mckey, $row); } } if (isset($row)) { $this->id = $row['id']; $this->number = $row['train_number']; $this->meta = json_decode($row['meta'], true); $this->provider = $row['provider']; $this->commodity = $row['commodity']; if ($row['operator_id'] > 0) { $this->Organisation = new Organisation($row['operator_id']); } $this->url = new Url(sprintf("%s/t/%s/%s", $this->Module->url, $this->provider, strtolower($this->number))); $this->url->edit = sprintf("%s?mode=edit", $this->url->url); } }
/** * Constructor * @since Version 3.9 * @param int $id The database ID of this train * @param string $provider The source of this timetable (default is "artc") */ public function __construct($id = false, $provider = "artc") { parent::__construct(); if ($id != false && $provider == "artc") { $query = "SELECT id FROM timetable_trains WHERE train_number LIKE ? AND provider = ?"; $id = $this->db->fetchOne($query, array("%" . $id . "%", $provider)); } $this->id = $id; $this->load(); }