<?php 
class Application_Model_Typefile extends MyWeb_Model_Database
{

    protected $_storageName = 'Typefile';

    protected $_formClasses = array(
        'insert' => 'typefileNew',
        'update' => 'typefileEdit',
        'search' => 'typefileSearch'
        );

    public function fetchEntry($id)
    {
        // databázový adaptér
        $db = $this->getStorage()->getAdapter();
        
        // vytvoří SELECT
        $select = $db->select();
        if (is_null($id)){
        	$select	->	from(array('T' => 'typefile'),
        						array('id_typeFile','typeFile_type'))
        ;
        }else {
        	$select	->	from(array('T' => 'typefile'),
        				array('id_typeFile','typeFile_type'))
        
        			->	where('T.id_typeFile = ?',$id);
        }
        // načítá údaje
        //echo "<p>".$select."</p>";
        $data['data'] = $db->fetchRow($select);
        return $data;
    }

    public function fetchEntries($data)
    {
        // databázový adaptér
        $db = $this->getStorage()->getAdapter();
        
        // vytvoří SELECT
        $select = $db	->	select()
        				->	from(array('T' => 'typefile'),
        					array('id_typeFile','typeFile_type'))
        ;
        // načítá údaje
         if (is_null($data)){
        	//echo "<p>kompletni vypis</p>";
        }else {
        	if (array_key_exists('id_typeFile', $data)){
        		if (!is_null($data['id_typeFile']) && (strcmp($data['id_typeFile'],"none") !== 0) && (strcmp($data['id_typeFile'],"") !== 0)){
        			$select	->	where('T.id_typeFile = ?',$data['id_typeFile']); 
        		}
        	}
        
        	if (array_key_exists('typeFile_type', $data)){
        		if (!is_null($data['typeFile_type']) && (strcmp($data['typeFile_type'],"none") !== 0) && (strcmp($data['typeFile_type'],"") !== 0)){
        			$select	->	where('T.typeFile_type = ?',$data['typeFile_type']); 
        		}
        	}
        
        }
        // načítá údaje
        //echo "<p>".$select."</p>";
        $data = $db->fetchAll($select);
        	return $data;
    }


}
