public function fetchByCategory($categoryName)
 {
     $resultSet = $this->getDbTable()->fetchAll('category LIKE "' . $categoryName . '"');
     $entries = array();
     foreach ($resultSet as $row) {
         $entry = new Application_Model_Megavideo();
         $entry->setId($row->id)->setDescription($row->description)->setLabel($row->label)->setCategory($row->category)->setIdVideo($row->idVideo);
         $entries[] = $entry;
     }
     return $entries;
 }
 public function addAction()
 {
     $request = $this->getRequest();
     $form = new Application_Form_Megavideo();
     $form->setAction($this->_helper->url('add'));
     $isAjax = $request->getParam('isAjax', false);
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($request->getPost())) {
             $idVideo = $form->getValue('idVideo');
             @(list($idVideo, $type) = explode('_', $idVideo));
             if ($type == 'd') {
                 // this is a megaupload->megavideo file. I need to find the real id
                 $idVideo = $this->_getRealMegavideoId($idVideo);
             }
             $video = new Application_Model_Megavideo($form->getValues());
             $video->setIdVideo($idVideo);
             // Nel caso in cui sia un edit request
             if (!is_null($request->getParam('id', null))) {
                 $video->setId($request->getParam('id', null));
             }
             $mapper = Application_Model_MegavideoMapper::i();
             $mapper->save($video);
             if ($isAjax) {
                 header('Content-Type:text/plain');
                 echo '1';
                 $this->_helper->viewRenderer->setNoRender(true);
                 $this->_helper->layout->disableLayout();
                 return;
             } else {
                 //return $this->_helper->redirector('index');
                 $this->_helper->redirector('category', 'megavideo', 'default', array('id' => urlencode($video->getCategory())));
             }
         }
     }
     if ($isAjax) {
         header('Content-Type:text/plain');
         echo '0';
         $this->_helper->viewRenderer->setNoRender(true);
         $this->_helper->layout->disableLayout();
     } else {
         $this->view->form = $form;
     }
 }