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

<?php 

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

class Castrados extends DBAccess implements IFilterable
{

	public function ParseFilter(array $filter)
	{
		$sql = '';

		if (isset($filter['SBA']) && $filter['SBA'] != "")
		{
			$sql.= " AND HBAE = " . DB::Number($filter['SBA']);
		}

		if (isset($filter['RP']) && $filter['RP'] != "")
		{
			$sql.= " AND RPEX = " . DB::Number($filter['RP']);
		}

		if (isset($filter['Animal']) && $filter['Animal'] != "")
		{
			$sql.= " AND NOMB LIKE '%" . DB::StringUnquoted($filter['Animal']) . "%'";
		}

		return $sql;
	}

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

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

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

		if ( !($oRow = $oRes->GetRow()) )
			return false;

		$Count = $oRow['Count'];
		$Count = ceil($Count);

		return $Count;
	}
	
	public function GetAll(array $filter = NULL, Page $oPage = NULL)
	{
		$sql = "SELECT * ";
		$sql.= " FROM tblCastrados ";
		$sql.= " WHERE 1 ";

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

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

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

		$arr = array();
		
		while ($oRow = $oRes->GetRow())	
		{	
			$oCastrado = new Castrado();
			$oCastrado->ParseFromArray($oRow);
			
			array_push($arr, $oCastrado);
			
			$oRes->MoveNext();
		}	
		
		return $arr;
	}
	
	public function GetAnimalBySBA($SBA, $RP, $Sexo)
	{
		$sql = "SELECT *";
		$sql.= " FROM tblCastrados ";
		$sql.= " WHERE 1 ";

		if ($Sexo != "")
			$sql.= " AND SEXO = ".$Sexo." ";

		if ($SBA != "")
			$sql.= " AND HBEX = '" .$SBA. "' ";

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

	public function GetBySba($SBA, $RP)
	{
		$sql = "SELECT *";
		$sql.= " FROM tblCastrados ";
		$sql.= " WHERE HBAE = '" .$SBA. "' ";
		$sql.= " AND RPEX = '".$RP."' ";

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

		while ($oRow = $oRes->GetRow())	
		{
			$oCastrado = new Castrado();
			$oCastrado->ParseFromArray($oRow);

			array_push($arr, $oCastrado);

			$oRes->MoveNext();
		}

		return $arr;	
	}
	
	
	public function GetNombreById($IdCastrado)
	{
		$sql = "SELECT * ";
		$sql.= " FROM tblCastrados ";
		$sql.= " WHERE IdCastrado = " . DB::Number($IdCastrado);	

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

		if (!($oRow = $oRes->GetRow()))
			return false;

		$oCastrado = new Castrado();
		$oCastrado->ParseFromArray($oRow);

		return $oCastrado->Nombre;		
	}
	
	public function GetById($IdCastrado)
	{
		$sql = "SELECT * ";
		$sql.= " FROM tblCastrados ";
		$sql.= " WHERE IdCastrado = " . DB::Number($IdCastrado);	

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

		if (!($oRow = $oRes->GetRow()))
			return false;

		$oCastrado = new Castrado();
		$oCastrado->ParseFromArray($oRow);

		return $oCastrado;		
	}
	
	
	public function GetByNombre($Nombre, $IdCastrado)
	{
		$sql = " SELECT * ";
		$sql.= " FROM tblCastrados ";
		$sql.= " WHERE WHERE 1 ";

		if (!($oRes = $this->GetQuery($sql)))
			return false;
			
		if (!($oRow = $oRes->GetRow()))
			return false;
		
		$oCastrado = new Castrado();
		$oCastrado->ParseFromArray($oRow);
		
		return $oCastrado;		
	}
	
	
	public function GetCountRows(array $filter = NULL)
	{
		$sql = "SELECT * ";
		$sql.= " FROM tblCastrados ";
		$sql.= " WHERE 1";
		
		if ($filter)
			$sql.= $this->ParseFilter($filter);

		if (!($oRes = $this->GetQuery($sql)))
			return false;
		
		$CountRows = $oRes->NumRows();
		
		return $CountRows;
	}
	
	
	public function Create(Castrado $oCastrado)
	{
		$arr = array
		(
			'IdPropietario'	=> DB::Number($oCastrado->IdPropietario),
			'RAZA'  		=> DB::String($oCastrado->RAZA),
			'HBAE' 			=> DB::String($oCastrado->HBAE),
			'RPEX' 			=> DB::String($oCastrado->RPEX),
			'NOMB' 			=> DB::String($oCastrado->NOMB),
			'SEXO' 			=> DB::String($oCastrado->SEXO),
			'ASOX' 			=> DB::String($oCastrado->ASOX),
			'HBEX' 			=> DB::String($oCastrado->HBEX),
			'RPET' 			=> DB::String($oCastrado->RPET),
			'ASOP' 			=> DB::String($oCastrado->ASOP),
			'HBAP' 			=> DB::String($oCastrado->HBAP),
			'RGSP' 			=> DB::String($oCastrado->RGSP),
			'RPPD' 			=> DB::String($oCastrado->RPPD),
			'ASOM' 			=> DB::String($oCastrado->ASOM),
			'HBAM' 			=> DB::String($oCastrado->HBAM),
			'RGSM' 			=> DB::String($oCastrado->RGSM),
			'RPMD' 			=> DB::String($oCastrado->RPMD),
			'ANLS' 			=> DB::String($oCastrado->ANLS),
			'RANA' 			=> DB::String($oCastrado->RANA),
			'CDPX' 			=> DB::String($oCastrado->CDPX),
			'NROC' 			=> DB::String($oCastrado->NROC),
			'REGI' 			=> DB::String($oCastrado->REGI),
			'CALI' 			=> DB::String($oCastrado->CALI),
			'VARI' 			=> DB::String($oCastrado->VARI),
			'APRB' 			=> DB::String($oCastrado->APRB),
			'TANA' 			=> DB::String($oCastrado->TANA),
			'PURE' 			=> DB::String($oCastrado->PURE),
			'FNAC' 			=> DB::Date($oCastrado->FNAC),
			'CPEL' 			=> DB::String($oCastrado->CPEL),
			'CCUE' 			=> DB::String($oCastrado->CCUE),
			'CCAB' 			=> DB::String($oCastrado->CCAB),
			'CMIE' 			=> DB::String($oCastrado->CMIE),
			'PROP' 			=> DB::String($oCastrado->PROP)
		);

		if (!$this->Insert('tblCastrados', $arr))
			return false;
			
		return $oCastrado;
	}
	
	
public function UpdateFNAC(Castrado $oCastrado)
	{
		$where = " IdCastrado = " . DB::Number($oCastrado->IdCastrado);
		
		$arr = array
		(
			'IdCastrado'	=> DB::Number($oCastrado->IdPdre),
			'FNAC' 	=> DB::Date($oCastrado->FNAC)
		);
		
		if (!DBAccess::Update('tblCastrados', $arr, $where))
			return false;
		
		return $oCastrado;
	}
	
	public function Update(Castrado $oCastrado)
	{
		$where = " IdCastrado = " . DB::Number($oCastrado->IdCastrado);
		
		$arr = array
		(
			'IdPropietario'	=> DB::Number($oCastrado->IdPropietario),
			'RAZA'  		=> DB::String($oCastrado->RAZA),
			'HBAE' 			=> DB::String($oCastrado->HBAE),
			'RPEX' 			=> DB::String($oCastrado->RPEX),
			'NOMB' 			=> DB::String($oCastrado->NOMB),
			'SEXO' 			=> DB::String($oCastrado->SEXO),
			'ASOX' 			=> DB::String($oCastrado->ASOX),
			'HBEX' 			=> DB::String($oCastrado->HBEX),
			'RPET' 			=> DB::String($oCastrado->RPET),
			'ASOP' 			=> DB::String($oCastrado->ASOP),
			'HBAP' 			=> DB::String($oCastrado->HBAP),
			'RGSP' 			=> DB::String($oCastrado->RGSP),
			'RPPD' 			=> DB::String($oCastrado->RPPD),
			'ASOM' 			=> DB::String($oCastrado->ASOM),
			'HBAM' 			=> DB::String($oCastrado->HBAM),
			'RGSM' 			=> DB::String($oCastrado->RGSM),
			'RPMD' 			=> DB::String($oCastrado->RPMD),
			'ANLS' 			=> DB::String($oCastrado->ANLS),
			'RANA' 			=> DB::String($oCastrado->RANA),
			'CDPX' 			=> DB::String($oCastrado->CDPX),
			'NROC' 			=> DB::String($oCastrado->NROC),
			'REGI' 			=> DB::String($oCastrado->REGI),
			'CALI' 			=> DB::String($oCastrado->CALI),
			'VARI' 			=> DB::String($oCastrado->VARI),
			'APRB' 			=> DB::String($oCastrado->APRB),
			'TANA' 			=> DB::String($oCastrado->TANA),
			'PURE' 			=> DB::String($oCastrado->PURE),
			'FNAC' 			=> DB::Date($oCastrado->FNAC),
			'CPEL' 			=> DB::String($oCastrado->CPEL),
			'CCUE' 			=> DB::String($oCastrado->CCUE),
			'CCAB' 			=> DB::String($oCastrado->CCAB),
			'CMIE' 			=> DB::String($oCastrado->CMIE),
			'PROP' 			=> DB::String($oCastrado->PROP)
		);
		
		if (!DBAccess::Update('tblCastrados', $arr, $where))
			return false;
		
		return $oCastrado;
	}
	

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

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

?>

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