<?php 
class Application_Model_SubjectHasSubject extends MyWeb_Model_Database
{

    protected $_storageName = 'SubjectHasSubject';

    protected $_formClasses = array(
        'insert' => 'SubjectHasSubjectNew',
        'update' => 'SubjectHasSubjectEdit',
        'search' => 'SubjectHasSubjectSearch'
        );

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


}
