AnonSec Team
Server IP : 10.2.73.233  /  Your IP : 216.73.216.59
Web Server : Apache/2.4.59 (Debian)
System : Linux polon 4.19.0-27-amd64 #1 SMP Debian 4.19.316-1 (2024-06-25) x86_64
User : www-data ( 33)
PHP Version : 5.6.40-64+0~20230107.71+debian10~1.gbp673146
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
MySQL : ON  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home/leksykografia/application/models/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/leksykografia/application/models/ProductMapper.php
<?php
class Application_Model_ProductMapper
{
	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_Product');
		}
		return $this->_dbTable;
	}

	public function save(Application_Model_Product $product)
	{
		$data = array(
            'product_type' => $product->getProductType(),
            'slug' => $product->getSlug(),
            'title1' => $product->getTitle1(),
			'title2' => $product->getTitle2(),
			'title3' => $product->getTitle3(),
			'title4' => $product->getTitle4(),
			'logo' => $product->getLogo(),
			'city' => $product->getCity(),
			'term_from' => $product->getTermFrom(),
			'term_to' => $product->getTermTo(),
			'title_small1' => $product->getTitleSmall1(),
		    'title_small2' => $product->getTitleSmall2(),
            'pdf' => $product->getPdf(),
			'program' => $product->getProgram(),
			'place' => $product->getPlace(),
			'price1' => $product->getPrice1(),
			'price2' => $product->getPrice2(),
			'price_to' => $product->getPriceTo(),
		    'active' => $product->getActive(),
			'created' => date('Y-m-d H:i:s')

		);

		if (null === ($id = $product->getId())) {
			unset($data['id']);
			return $this->getDbTable()->insert($data);
		} else {
			return $this->getDbTable()->update($data, array('id = ?' => $id));
		}
	}
	
    public function delete($productId)
	{
		return $this->getDbTable()->delete('id = '.$productId);
	}

	public function find($id, Application_Model_Product $product)
	{
		$result = $this->getDbTable()->find($id);
		if (0 == count($result)) {
			return false;
		}
		$row = $result->current();
		
		$product->setId($row->id)
		->setProductType($row->product_type)
		->setSlug($row->slug)
		->setTitle1($row->title1)
		->setTitle2($row->title2)
		->setTitle3($row->title3)
		->setTitle4($row->title4)
		->setLogo($row->logo)
		->setCity($row->city)
		->setTermFrom($row->term_from)
		->setTermTo($row->term_to)
		->setTitleSmall1($row->title_small1)
		->setTitleSmall2($row->title_small2)
		->setPdf($row->pdf)
		->setProgram($row->program)
		->setPlace($row->place)
		->setPrice1($row->price1)
		->setPrice2($row->price2)
		->setPriceTo($row->price_to)
		->setActive($row->active)
		->setCreated($row->created)
		->setTemplate($row->template);
		
		return true;
	}
	
	public function fetchAll()
	{
	    $select = $this->getDbTable()->select()
	   ->order('term_from asc');
	    $resultSet = $this->getDbTable()->fetchAll($select);
		$entries   = array();
		foreach ($resultSet as $row) {
			$entry = new Application_Model_Product();
			$entry->setId($row->id)
		->setProductType($row->product_type)
		->setSlug($row->slug)
		->setTitle1($row->title1)
		->setTitle2($row->title2)
		->setTitle3($row->title3)
		->setTitle4($row->title4)
		->setLogo($row->logo)
		->setCity($row->city)
		->setTermFrom($row->term_from)
		->setTermTo($row->term_to)
		->setTitleSmall1($row->title_small1)
		->setTitleSmall2($row->title_small2)
		->setPdf($row->pdf)
		->setProgram($row->program)
		->setPlace($row->place)
		->setPrice1($row->price1)
		->setPrice2($row->price2)
		->setPriceTo($row->price_to)
		->setActive($row->active)
		->setCreated($row->created)
		->setTemplate($row->template);
		
		$entries[] = $entry;
		}
		return $entries;
	}
	
	public function fetchAllActiveForIndex($categoryId=false)
	{
		$select = $this->getDbTable()->select()
		->where('active = ?', 'Y')
		->where('product_type IN (1,2,3)')
		->where('term_from < ?', date("Y-m-d"))
		->order('term_from asc');
		if($categoryId)
			$select->from(array('p' => 'product',array('*')))
			->setIntegrityCheck(false)
			->join(array('pc' => 'product_categories'),
            'p.id = pc.product_id',null)
            ->where("pc.product_category_id = ?", $categoryId);
		$resultSet = $this->getDbTable()->fetchAll($select);
		$entries1   = array();
		foreach ($resultSet as $row) {
			$entry = new Application_Model_Product();
			$entry->setId($row->id)
			->setProductType($row->product_type)
			->setSlug($row->slug)
			->setTitle1($row->title1)
			->setTitle2($row->title2)
			->setTitle3($row->title3)
			->setTitle4($row->title4)
			->setLogo($row->logo)
			->setCity($row->city)
			->setTermFrom($row->term_from)
			->setTermTo($row->term_to)
			->setTitleSmall1($row->title_small1)
			->setTitleSmall2($row->title_small2)
			->setPdf($row->pdf)
			->setProgram($row->program)
			->setPlace($row->place)
			->setPrice1($row->price1)
			->setPrice2($row->price2)
			->setPriceTo($row->price_to)
			->setActive($row->active)
			->setCreated($row->created)
			->setTemplate($row->template);
			$entries1[] = $entry;
		}
		
		$select = $this->getDbTable()->select()
		->where('active = ?', 'Y')
		->where('product_type IN (1,2,3)')
		->where('term_from >= ?', date("Y-m-d"))
		->order('term_from asc');
		if($categoryId)
		$select->from(array('p' => 'product',array('*')))
		->setIntegrityCheck(false)
		->join(array('pc' => 'product_categories'),
		            'p.id = pc.product_id',null)
		->where("pc.product_category_id = ?", $categoryId);
		$resultSet = $this->getDbTable()->fetchAll($select);
		$entries2   = array();
		foreach ($resultSet as $row) {
			$entry = new Application_Model_Product();
			$entry->setId($row->id)
			->setProductType($row->product_type)
			->setSlug($row->slug)
			->setTitle1($row->title1)
			->setTitle2($row->title2)
			->setTitle3($row->title3)
			->setTitle4($row->title4)
			->setLogo($row->logo)
			->setCity($row->city)
			->setTermFrom($row->term_from)
			->setTermTo($row->term_to)
			->setTitleSmall1($row->title_small1)
			->setTitleSmall2($row->title_small2)
			->setPdf($row->pdf)
			->setProgram($row->program)
			->setPlace($row->place)
			->setPrice1($row->price1)
			->setPrice2($row->price2)
			->setPriceTo($row->price_to)
			->setActive($row->active)
			->setCreated($row->created)
			->setTemplate($row->template);
			$entries2[] = $entry;
		}
		return array($entries1,$entries2);

	}
	
	public function fetchAllByType($type)
	{
		$select = $this->getDbTable()->select()
		->where("product_type = ?", $type)
		->order('term_from asc');
		$resultSet = $this->getDbTable()->fetchAll($select);
		$entries   = array();
		foreach ($resultSet as $row) {
			$entry = new Application_Model_Product();
			$entry->setId($row->id)
			->setProductType($row->product_type)
			->setSlug($row->slug)
			->setTitle1($row->title1)
			->setTitle2($row->title2)
			->setTitle3($row->title3)
			->setTitle4($row->title4)
			->setLogo($row->logo)
			->setCity($row->city)
			->setTermFrom($row->term_from)
			->setTermTo($row->term_to)
			->setTitleSmall1($row->title_small1)
			->setTitleSmall2($row->title_small2)
			->setPdf($row->pdf)
			->setProgram($row->program)
			->setPlace($row->place)
			->setPrice1($row->price1)
			->setPrice2($row->price2)
			->setPriceTo($row->price_to)
			->setActive($row->active)
			->setCreated($row->created)
			->setTemplate($row->template);
	
			$entries[] = $entry;
		}
		return $entries;
	}
	
	public function fetchAllActiveByType($type, $order=false)
	{
		$select = $this->getDbTable()->select()
		->where("product_type = ?", $type)
		->where("active = 'Y'");
		if(!$order)
			$select->order('term_from asc');
		elseif($order)
			$select->order($order);
		$resultSet = $this->getDbTable()->fetchAll($select);
		$entries   = array();
		foreach ($resultSet as $row) {
			$entry = new Application_Model_Product();
			$entry->setId($row->id)
			->setProductType($row->product_type)
			->setSlug($row->slug)
			->setTitle1($row->title1)
			->setTitle2($row->title2)
			->setTitle3($row->title3)
			->setTitle4($row->title4)
			->setLogo($row->logo)
			->setCity($row->city)
			->setTermFrom($row->term_from)
			->setTermTo($row->term_to)
			->setTitleSmall1($row->title_small1)
			->setTitleSmall2($row->title_small2)
			->setPdf($row->pdf)
			->setProgram($row->program)
			->setPlace($row->place)
			->setPrice1($row->price1)
			->setPrice2($row->price2)
			->setPriceTo($row->price_to)
			->setActive($row->active)
			->setCreated($row->created)
			->setTemplate($row->template);
	
			$entries[] = $entry;
		}
		return $entries;
	}
	
	
	
	
	
	
	

}

AnonSec - 2021