summaryrefslogblamecommitdiffstats
path: root/application/models/BootMenuEntriesMapper.php
blob: 2dac0856c5271ca67d84e11bf6620ddd10fbdb16 (plain) (tree)
1
2
3
4
5
6
7

     
                                             
 
        
                            
 




                                                  
 











                                                                                   
                                                                                       




                                       
                                                                               

                
                                                                                                                                                                                                                                                                                           
 

                                                                  

                                                           
                                                                                                                    







                                                                                 
                                                                                           


                 
                                                                                    







                                                         
                                                                                                                                                                                            






                                                             
                                                                         
                        
                                                                                                                                                                                                
 

                                            

                                


        

 
<?php

class Application_Model_BootMenuEntriesMapper
{
	
	protected $_dbTable;

	public function setDbTable($dbTable)
	{
		if (is_string($dbTable)) {
			$dbTable = new $dbTable();
		}

		if (!$dbTable instanceof Zend_Db_Table_Abstract) {
			throw new Exception('Invalid table data gateway provided');
		}

		$this->_dbTable = $dbTable;
		
		return $this;
	}

	public function getDbTable()
	{
		if (null === $this->_dbTable) {
			$this->setDbTable('Application_Model_DbTable_BootMenuEntries');
		}
		
		return $this->_dbTable;
	}

	public function save(Application_Model_BootMenuEntries $botmenuentries)
	{
		
		$data = array('bootosID'=> $botmenuentries->getBootosID() ,'bootmenuID'=> $botmenuentries->getBootmenuID() ,'configID'=> $botmenuentries->getConfigID() ,'title'=> $botmenuentries->getTitle() ,'kcl'=> $botmenuentries->getKcl() ,'order'=> $botmenuentries->getOrder() );

		if (null === ($id1 = $botmenuentries->getID()) ) {
		
			$this->getDbTable()->insert($data);
		} else {
			$this->getDbTable()->update($data, array('bootosID = ?' => $id1, 'bootmenuID = ?' => $id2));
		}
	}
	
	public function delete(Application_Model_BootMenuEntries $botmenuentries)
	{
		if (null === ($id = $botmenuentries->getID()) ) {
			return;
		} else {
			$this->getDbTable()->delete(array('bootmenuentriesID = ?' => $id));
		}
	}

	public function find($id, Application_Model_BootMenuEntries $botmenuentries)
	{
		$result = $this->getDbTable()->find($id);
		if (0 == count($result)) {
			return;
		}

		$row = $result->current();
		
		$botmenuentries->setBootosID($row->bootosID)->setBootmenuID($row->bootmenuID)->setTitle($row->title)->setConfigID($row->configID)->setKcl($row->kcl)->setOrder($row->order);
	}

	public function fetchAll()
	{
		$resultSet = $this->getDbTable()->fetchAll();
		$entries   = array();
		foreach ($resultSet as $row) {
			$entry = new Application_Model_BootMenuEntries();
			
			$entry->setBootosID($row->bootosID)->setBootmenuID($row->bootmenuID)->setTitle($row->title)->setConfigID($row->configID)->setKcl($row->kcl)->setOrder($row->order);	

			$entries[] = $entry;
		}
		return $entries;
	}


	
}