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

<?php 

require_once('class.dbaccess.php');
require_once('class.pelo.php');
require_once('class.filter.php');
require_once('class.page.php');

class Pelos extends DBAccess implements IFilterable
{
	public function ParseFilter(array $filter)
	{
		$sql = '';
		
		$sql.= " WHERE Nombre LIKE '%" . DB::StringUnquoted($filter['Nombre']) . "%'";
		
		return $sql;
	}


	public function GetPagesCount(Page $oPage, $filter = false)
	{	
		$sql = "SELECT COUNT(1) / " . DB::Number($oPage->Size) . " AS Count";
		$sql.= " FROM tblPelos";
		
		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 GetAll(array $filter = NULL, Page $oPage = NULL)
	{
		$sql = "SELECT *";
		$sql.= " FROM tblPelos";

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

		$sql.= " ORDER BY Nombre";

		if ($oPage != NULL)
			$sql.= " " . Pageable::ParsePage($oPage);
						
		if (!($oRes = $this->GetQuery($sql)))
			return false;
			
		$arr = array();
			
		while ($oRow = $oRes->GetRow())	
		{	
			$oPelo = new Pelo();
			$oPelo->ParseFromArray($oRow);
			
			array_push($arr, $oPelo);
			
			$oRes->MoveNext();
		}	
		
		return $arr;		
	}

	public function GetNombreById($IdPelo)
	{
		$sql = "SELECT Nombre";
		$sql.= " FROM tblPelos";
		$sql.= " WHERE IdPelo = " . DB::Number($IdPelo);	

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

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

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

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

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

		$sql.= " ORDER BY Nombre";
		
		if (!($oRes = $this->GetQuery($sql)))
			return false;
		
		$CountRows = $oRes->NumRows();
		
		return $CountRows;
	}
	
	
	public function Create(Pelo $oPelo)
	{
		$arr = array(
			'Nombre' => DB::String($oPelo->Nombre),
			//'Estado' => DB::String($_SESSION['Estado'])
			'Estado' => DB::String('A')
		);
		
		if (!$this->Insert('tblPelos', $arr))
			return false;
			
		return $oPelo;
	}
	
	
	public function Update(Pelo $oPelo)
	{
		$where = " IdPelo = " . DB::Number($oPelo->IdPelo);
		
		$arr = array(
			'Nombre' => DB::String($oPelo->Nombre),
			//'Estado' => DB::String($_SESSION['Estado'])
			'Estado' => DB::String('A')
		);		
		
		if (!DBAccess::Update('tblPelos', $arr, $where))
			return false;
		
		return $oPelo;
	}
	

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

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

?>

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