przewiń do treści

Zend Framework od podstaw

Włodzimierz Gajda

public function showAction()
{
    $Plik = new Application_Model_DbTable_Plik();
    $slug = $this->getRequest()->getParam('slug');
    $select = $Plik->select()->where('slug = ?', $slug);
    $this->view->plik = $Plik->fetchRow($select);
    if (!$this->view->plik) {
        throw new Zend_Controller_Action_Exception('Błąd #1!', 404);
    }

    $this->getResponse()
        ->setHeader('Content-Type', $this->view->plik['typmime'])
        ->appendBody($this->view->plik['dane']);

    $this->_helper->layout()->disableLayout();
    $this->_helper->viewRenderer->setNoRender();
}

Listing 24.5. Metoda showAction() akcji index/show

Rozdział 24. Zapisywanie w bazie danych plików binarnych

listing-24-05.txt