<?php
class RebricekController extends Zend_Controller_Action {
	public function indexAction(){
		$this->_redirect('/rebricek/top');
	}
	
	public function topAction(){
		$rebricek = new Model_DbTable_Rebricky();
		$statement1 = $rebricek->select()->order('id DESC');
		// Ziskame hodnotu ID najnovsieho rebricku
		$result = $rebricek->fetchRow($statement1);
		$this->view->rebricek = $result;
		$videoklipy = new Model_DbTable_RebricekNaKlip();
		$statement2 = $videoklipy->select('klipy')
								 ->where('rebriceknaklip.rebricek_id = ?', $result->id)
								 ->setIntegrityCheck(false)
								 ->joinLeft('klipy','rebriceknaklip.klip_id = klipy.id', array('p' => 'id',  'title', 'url')); 
       $this->view->videoklipy = $videoklipy->fetchAll($statement2);								 				
	}
}
?>