Esempio n. 1
0
    /**
     * Returns all auth_ticket records even those that have expired but not removed yet.
     * 
     * @return AuthTicketModel[]
     * @throws ControllerException
     * @SuppressWarnings indentation
     */
    public function getAll()
    {
        $models = array();
        $sql = <<<SQL
SELECT auth_ticket
     , created
     , updated
     , expires
  FROM auth_ticket
 ORDER BY expires DESC
SQL;
        $stmt = $this->_dbh->prepare($sql);
        if (!$stmt) {
            throw new ControllerException('Failed to prepare SELECT statement. (' . $this->_dbh->error . ')');
        }
        if (!$stmt->execute()) {
            throw new ControllerException('Failed to execute SELECT statement. (' . $this->_dbh->error . ')');
        }
        $auth_ticket = $created = $updated = $expires = null;
        $stmt->bind_result($auth_ticket, $created, $updated, $expires);
        while ($stmt->fetch()) {
            $model = new AuthTicketModel();
            $model->setAuthTicket($auth_ticket);
            $model->setCreated($created);
            $model->setUpdated($updated);
            $model->setExpires($expires);
            $models[] = $model;
        }
        return $models;
    }