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

<?php 

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

class Pdres 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 tblPdre pr";
		$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 GetAllFNAC()
	{
		$sql = "SELECT IdPdre, FNAC ";
		$sql.= " FROM tblPdre ";
		$sql.= " WHERE LENGTH(FNAC) >= 9 ";

		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())	
		{	
			$oPdre = new Pdre();
			$oPdre->ParseFromArray($oRow);

			array_push($arr, $oPdre);

			$oRes->MoveNext();
		}	

		return $arr;
	}
	
	
	public function GetAll(array $filter = NULL, Page $oPage = NULL)
	{
		$sql = "SELECT * ";
		$sql.= " FROM tblPdre ";
		$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())	
		{	
			$oPdre = new Pdre();
			$oPdre->ParseFromArray($oRow);

			array_push($arr, $oPdre);

			$oRes->MoveNext();
		}	

		return $arr;
	}

	public function GetBySBA($SBA, $RP)
	{
		$sql = "SELECT * ";
		$sql.= " FROM tblPdre ";
		$sql.= " WHERE 1 ";
		
		if ($SBA != "")
			$sql.= " AND HBAE = '" .$SBA. "' ";

		if ($RP != "")
			$sql .= " AND RPEX = '".$RP."'";

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

		$arr = array();

		while ($oRow = $oRes->GetRow())	
		{
			$oPdre = new Pdre();
			$oPdre->ParseFromArray($oRow);

			array_push($arr, $oPdre);

			$oRes->MoveNext();
		}

		return $arr;
	}

	public function GetAnimalBySBA($SBA, $RP, $RGST = NULL)
	{
		$sql = "SELECT IdPdre, HBAE, RPEX, NOMB, PROP, HBAP, RPPD, HBAM, RPMD, FNAC, CPEL, RGST, ASOC, ASOP, ASOM, RGSM, RGSP ";
		$sql.= " FROM tblPdre ";
		$sql.= " WHERE 1 ";
		
		if ($SBA != "")
			$sql.= " AND HBAE = '" .$SBA. "' ";
		else
			$sql.= " 1=0";

		//if ($RP != "")
			//$sql .= " AND RPEX = '".$RP."'";
		
		if ($RGST != "")
			$sql.= " AND RGST = '" . $RGST . "'";

		if (!($oRes = $this->GetQuery($sql)))
			return false;
			
		if (!($oRow = $oRes->GetRow()))
			return false;
		
		$oPdre = new Pdre();
		$oPdre->ParseFromArray($oRow);

		return $oPdre;		
	}
	
	public function GetNombreBySBA($SBA)
	{
		$sql = " SELECT NOMB ";
		$sql.= " FROM tblPdre ";
		$sql.= " WHERE HBAE = '".$SBA."'";

		if (!($oRes = $this->GetQuery($sql)))
			return false;
			
		if (!($oRow = $oRes->GetRow()))
			return false;
		
		$oPdre = new Pdre();
		$oPdre->ParseFromArray($oRow);
		
		return $oPdre->NOMB;		
	}
	
	public function GetByID($IdPrde)
	{
		$sql = " SELECT * ";
		$sql.= " FROM tblPdre ";
		$sql.= " WHERE IdPdre = '".$IdPrde."'";

		if (!($oRes = $this->GetQuery($sql)))
			return false;
			
		if (!($oRow = $oRes->GetRow()))
			return false;
		
		$oPdre = new Pdre();
		$oPdre->ParseFromArray($oRow);
		
		return $oPdre;		
	}
	
	public function GetByNombre($Nombre, $IdPrde)
	{
		$sql = " SELECT * ";
		$sql.= " FROM tblPdre ";
		$sql.= " WHERE 1 ";

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

		$sql.= " ORDER BY HBAE, NOMB ASC";
		
		if (!($oRes = $this->GetQuery($sql)))
			return false;
		
		$CountRows = $oRes->NumRows();
		
		return $CountRows;
	}
	
	
	public function Create(Pdre $oPdre)
	{
		$arr = array
		(
			'IdPdre'	=> DB::Number($oPdre->IdPdre),
			'RAZA' 		=> DB::String($oPdre->RAZA),
			'RGST' 		=> DB::String($oPdre->RGST),
			'VARI' 		=> DB::String($oPdre->VARI),
			'ASOC' 		=> DB::String($oPdre->ASOC),
			'HBAE' 		=> DB::String($oPdre->HBAE),
			'CDPX' 		=> DB::String($oPdre->CDPX),
			'RPEX' 		=> DB::String($oPdre->RPEX),
			'NOMB' 		=> DB::String($oPdre->NOMB),
			'CBAJ' 		=> DB::String($oPdre->CBAJ),
			'OBSI' 		=> DB::String($oPdre->OBSI),
			'DADO' 		=> DB::String($oPdre->DADO),
			'PROP' 		=> DB::String($oPdre->PROP),
			'CRIA' 		=> DB::String($oPdre->CRIA),
			'TRAN' 		=> DB::String($oPdre->TRAN),
			'ANLS' 		=> DB::String($oPdre->ANLS),
			'RANA' 		=> DB::String($oPdre->RANA),
			'CALG' 		=> DB::String($oPdre->CALG),
			'APRB' 		=> DB::String($oPdre->APRB),
			'SIET' 		=> DB::String($oPdre->SIET),
			'DONA' 		=> DB::String($oPdre->DONA),
			'MELL' 		=> DB::String($oPdre->MELL),
			'TRNS' 		=> DB::String($oPdre->TRNS),
			'TSER' 		=> DB::String($oPdre->TSER),
			'EMBA' 		=> DB::String($oPdre->EMBA),
			'COLO' 		=> DB::String($oPdre->COLO),
			'RGSP' 		=> DB::String($oPdre->RGSP),
			'VARP' 		=> DB::String($oPdre->VARP),
			'ASOP' 		=> DB::String($oPdre->ASOP),
			'HBAP' 		=> DB::String($oPdre->HBAP),
			'RPPD' 		=> DB::String($oPdre->RPPD),
			'RGSM' 		=> DB::String($oPdre->RGSM),
			'VARM' 		=> DB::String($oPdre->VARM),
			'ASOM' 		=> DB::String($oPdre->ASOM),
			'HBAM' 		=> DB::String($oPdre->HBAM),
			'RPMD' 		=> DB::String($oPdre->RPMD),
			'RPTI' 		=> DB::String($oPdre->RPTI),
			'FNAC' 		=> DB::Date($oPdre->FNAC),
			'FBAJ' 		=> DB::String($oPdre->FBAJ),
			'FESB' 		=> DB::String($oPdre->FESB),
			'FOBS' 		=> DB::String($oPdre->FOBS),
			'FTRF' 		=> DB::String($oPdre->FTRF),
			'FSER' 		=> DB::String($oPdre->FSER),
			'CPEL' 		=> DB::String($oPdre->CPEL),
			'CCUE' 		=> DB::String($oPdre->CCUE),
			'CCAB' 		=> DB::String($oPdre->CCAB),
			'CMIE' 		=> DB::String($oPdre->CMIE),
			'RPNU' 		=> DB::String($oPdre->RPNU),
			'APDO' 		=> DB::String($oPdre->APDO),
			'PENA' 		=> DB::String($oPdre->PENA),
			'PEDE' 		=> DB::String($oPdre->PEDE),
			'PEFI' 		=> DB::String($oPdre->PEFI),
			'EPNA' 		=> DB::String($oPdre->EPNA),
			'EPDE' 		=> DB::String($oPdre->EPDE),
			'EPFI' 		=> DB::String($oPdre->EPFI),
			'NROC' 		=> DB::String($oPdre->NROC),
			'SIGLA' 	=> DB::String($oPdre->SIGLA),
			'SIGPA' 	=> DB::String($oPdre->SIGPA),
			'SIGMA' 	=> DB::String($oPdre->SIGMA),
			'PURE' 		=> DB::String($oPdre->PURE),
			'TANA' 		=> DB::String($oPdre->TANA),
			'IdProd'	=> DB::Number($oPdre->IdProd),
			'IdPa'		=> DB::Number($oPdre->IdPa),
			'IdMa'		=> DB::Number($oPdre->IdMa),
			'IdPPdre'	=> DB::Number($oPdre->IdPPdre),
			'IdPExtr'	=> DB::Number($oPdre->IdPExtr),
			'IdEExis'	=> DB::Number($oPdre->IdEExis),
			'IdEExtr'	=> DB::Number($oPdre->IdEExtr)
		);

		if (!$this->Insert('tblPdre', $arr))
			return false;

		
		$oPdre->IdPdre = DBAccess::GetLastInsertId();
			
		return $oPdre;
	}
	
	public function UpdateFNAC(Pdre $oPdre)
	{
		$where = " IdPdre = " . DB::Number($oPdre->IdPdre);
		
		$arr = array
		(
			'IdPdre'=> DB::Number($oPdre->IdPdre),
			'FNAC' 	=> DB::Date($oPdre->FNAC)
		);
		
		if (!DBAccess::Update('tblPdre', $arr, $where))
			return false;
		
		return $oPdre;
	}
	
	public function Update(Pdre $oPdre)
	{
		$where = " IdPdre = " . DB::Number($oPdre->IdPdre);
		
		$arr = array
		(
			'IdPdre'	=> DB::Number($oPdre->IdPdre),
			'RAZA' 		=> DB::String($oPdre->RAZA),
			'RGST' 		=> DB::String($oPdre->RGST),
			'VARI' 		=> DB::String($oPdre->VARI),
			'ASOC' 		=> DB::String($oPdre->ASOC),
			'HBAE' 		=> DB::String($oPdre->HBAE),
			'CDPX' 		=> DB::String($oPdre->CDPX),
			'RPEX' 		=> DB::String($oPdre->RPEX),
			'NOMB' 		=> DB::String($oPdre->NOMB),
			'CBAJ' 		=> DB::String($oPdre->CBAJ),
			'OBSI' 		=> DB::String($oPdre->OBSI),
			'DADO' 		=> DB::String($oPdre->DADO),
			'PROP' 		=> DB::String($oPdre->PROP),
			'CRIA' 		=> DB::String($oPdre->CRIA),
			'TRAN' 		=> DB::String($oPdre->TRAN),
			'ANLS' 		=> DB::String($oPdre->ANLS),
			'RANA' 		=> DB::String($oPdre->RANA),
			'CALG' 		=> DB::String($oPdre->CALG),
			'APRB' 		=> DB::String($oPdre->APRB),
			'SIET' 		=> DB::String($oPdre->SIET),
			'DONA' 		=> DB::String($oPdre->DONA),
			'MELL' 		=> DB::String($oPdre->MELL),
			'TRNS' 		=> DB::String($oPdre->TRNS),
			'TSER' 		=> DB::String($oPdre->TSER),
			'EMBA' 		=> DB::String($oPdre->EMBA),
			'COLO' 		=> DB::String($oPdre->COLO),
			'RGSP' 		=> DB::String($oPdre->RGSP),
			'VARP' 		=> DB::String($oPdre->VARP),
			'ASOP' 		=> DB::String($oPdre->ASOP),
			'HBAP' 		=> DB::String($oPdre->HBAP),
			'RPPD' 		=> DB::String($oPdre->RPPD),
			'RGSM' 		=> DB::String($oPdre->RGSM),
			'VARM' 		=> DB::String($oPdre->VARM),
			'ASOM' 		=> DB::String($oPdre->ASOM),
			'HBAM' 		=> DB::String($oPdre->HBAM),
			'RPMD' 		=> DB::String($oPdre->RPMD),
			'RPTI' 		=> DB::String($oPdre->RPTI),
			'FNAC' 		=> DB::Date($oPdre->FNAC),
			'FBAJ' 		=> DB::String($oPdre->FBAJ),
			'FESB' 		=> DB::String($oPdre->FESB),
			'FOBS' 		=> DB::String($oPdre->FOBS),
			'FTRF' 		=> DB::String($oPdre->FTRF),
			'FSER' 		=> DB::String($oPdre->FSER),
			'CPEL' 		=> DB::String($oPdre->CPEL),
			'CCUE' 		=> DB::String($oPdre->CCUE),
			'CCAB' 		=> DB::String($oPdre->CCAB),
			'CMIE' 		=> DB::String($oPdre->CMIE),
			'RPNU' 		=> DB::String($oPdre->RPNU),
			'APDO' 		=> DB::String($oPdre->APDO),
			'PENA' 		=> DB::String($oPdre->PENA),
			'PEDE' 		=> DB::String($oPdre->PEDE),
			'PEFI' 		=> DB::String($oPdre->PEFI),
			'EPNA' 		=> DB::String($oPdre->EPNA),
			'EPDE' 		=> DB::String($oPdre->EPDE),
			'EPFI' 		=> DB::String($oPdre->EPFI),
			'NROC' 		=> DB::String($oPdre->NROC),
			'SIGLA' 	=> DB::String($oPdre->SIGLA),
			'SIGPA' 	=> DB::String($oPdre->SIGPA),
			'SIGMA' 	=> DB::String($oPdre->SIGMA),
			'PURE' 		=> DB::String($oPdre->PURE),
			'TANA' 		=> DB::String($oPdre->TANA),
			'IdProd'	=> DB::Number($oPdre->IdProd),
			'IdPa'		=> DB::Number($oPdre->IdPa),
			'IdMa'		=> DB::Number($oPdre->IdMa),
			'IdPPdre'	=> DB::Number($oPdre->IdPPdre),
			'IdPExtr'	=> DB::Number($oPdre->IdPExtr),
			'IdEExis'	=> DB::Number($oPdre->IdEExis),
			'IdEExtr'	=> DB::Number($oPdre->IdEExtr)
		);
		
		if (!DBAccess::Update('tblPdre', $arr, $where))
			return false;
		
		return $oPdre;
	}
	

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

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

?>

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