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

Mister Spy

Current Path : /home/caballoscriollos/public_html/espanol/library/
Upload File :
Current File : /home/caballoscriollos/public_html/espanol/library/class.videos.php

<?php 

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

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


	public function GetPagesCount(Page $oPage, $filter = false)
	{	
		$sql = "SELECT COUNT(1) / " . DB::Number($oPage->Size) . " AS Count";
		$sql.= " FROM videos v";
		
		if ($filter)
			$sql.= " " . $this->ParseFilter($filter);

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

		if ( !($oRow = $oRes->GetRow()) )
			return false;
		
		$Count = $oRow['Count'];
		
		return ceil($Count);
	}
	
	public function GetLast($Cantidad)
	{
		$sql = " SELECT DISTINCT v.*";
		$sql.= " FROM videos v";
		//$sql.= " WHERE u.Destacado = 1";
		$sql.= " ORDER BY orden DESC, videoID DESC";
		$sql.= " LIMIT " . DB::Number($Cantidad);

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

		while ($oRow = $oRes->GetRow())	
		{	
			$oVideo = new Video();
			$oVideo->ParseFromArray($oRow);
			
			array_push($arr, $oVideo);
			
			$oRes->MoveNext();
		}	
		
		return $arr;		
	}

	public function GetCountRows(array $filter = NULL)
	{
		$sql = "SELECT v.*";
		$sql.= " FROM videos v";

		if ($filter)
			$sql.= $this->ParseFilter($filter);

		$sql.= " ORDER BY video ASC";

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

	public function GetAll(array $filter = NULL, Page $oPage = NULL)
	{
		$sql = "SELECT v.*";
		$sql.= " FROM videos v";

		if ($filter)
			$sql.= $this->ParseFilter($filter);

		$sql.= " ORDER BY orden DESC";

		if ($oPage != NULL)
			$sql.= " " . Pageable::ParsePage($oPage);

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

		$arr = array();

		while ($oRow = $oRes->GetRow())	
		{
			$oVideo = new Video();
			$oVideo->ParseFromArray($oRow);

			array_push($arr, $oVideo);

			$oRes->MoveNext();
		}

		return $arr;
	}
	

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

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

	public function Create(Video $oVideo)
	{
		$arr = array
		(
			'videoID'	=> DB::Number($oVideo->videoID),
			'video'		=> DB::String($oVideo->video)
		);
		
		if (!$this->Insert('videos', $arr))
			return false;
			
		return $oVideo;
	}
	
	
	public function Update(Video $oVideo)
	{
		$where = " videoID = " . DB::Number($oVideo->videoID);
		
		$arr = array
		(
			'video'		=> DB::String($oVideo->video)
		);
		
		if (!DBAccess::Update('videos', $arr, $where))
			return false;
		
		return $oVideo;
	}
	

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

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

?>

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