/** * Return the LAST ordered entry with this id * * @param string $id Required grouping ID. * @return array */ public function getLast($id = null) { if ($id === null) { throw new Exception("Coder error. getFirst requires an ID"); } self::checkDatabase(); if (self::$dbGetLast === false) { self::$dbGetLast = self::$db->prepare("SELECT `key` FROM `" . self::$dbname . "` WHERE `module` = :mod AND `id` = :id ORDER BY `key` DESC LIMIT 1"); } if ($this->classOverride) { $mod = $this->classOverride; $this->classOverride = false; } else { $mod = get_class($this); } $query[':mod'] = $mod; $query[':id'] = $id; try { self::$dbGetLast->execute($query); } catch (Exception $e) { self::checkException($e); } $ret = self::$dbGetLast->fetchAll(PDO::FETCH_COLUMN, 0); return $ret[0]; }