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