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

<?php 

require_once('class.dbaccess.php');
require_once('class.registroapp.php');
require_once('class.usuario.php');
require_once('class.filter.php');
require_once('class.page.php');
require_once('class.estados.php');

class RegistrosApp extends DBAccess implements IFilterable
{
	public function ParseFilter(array $filter)
	{
		$sql = '';
		
		if ((isset($filter['IdUsuario'])) && ($filter['IdUsuario'] != ''))
		{
			$sql.= " AND s.IdUsuario = " . DB::Number($filter['IdUsuario']);
		}
		
		if ((isset($filter['IdTipoUsuario'])) && ($filter['IdTipoUsuario'] != ''))
		{
			$sql.= " AND u.IdTipoUsuario = " . DB::Number($filter['IdTipoUsuario']);
		}
		
		if ((isset($filter['Plataforma'])) && ($filter['Plataforma'] != ''))
		{
			$sql.= " AND (s.Plataforma = " . DB::String($filter['Plataforma']);
			if ($filter['Plataforma'] == 'iPhone')
				$sql.= " OR s.Plataforma = 'iPad'";
			$sql.= ")";
		}

		return $sql;
	}


	public function GetAll(array $filter = NULL, Page $oPage = NULL)
	{
		$sql = "SELECT s.*";
		$sql.= " FROM tblRegistrosApp s";
		$sql.= " INNER JOIN tblUsuarios u ON s.IdUsuario = u.IdUsuario";
		$sql.= " WHERE CodigoRegistro <> 'BLACKLISTED'";
		//$sql.= " AND CodigoRegistro = '8ad2fd73919d576a273e7c2e43c4cd1dc77d45e08c298ef0f9d07c6314556e66'";
		$sql.= ($filter) ? $this->ParseFilter($filter) : "";
		$sql.= " GROUP BY s.IdRegistro, CodigoRegistro";
		$sql.= ($oPage) ? Pageable::ParsePage($oPage) : "";
		
		if (!($oRes = $this->GetQuery($sql)))
			return false;
			
		$arr = array();
			
		while ($oRow = $oRes->GetRow())	
		{	
			$oRegistroApp = new RegistroApp();
			$oRegistroApp->ParseFromArray($oRow);
			
			array_push($arr, $oRegistroApp);
			
			$oRes->MoveNext();
		}	
		
		return $arr;		
	}
	
	
	public function GetAllByUsuario(Usuario $oUsuario, array $filter = NULL)
	{
		$arr = array();
	
		$sql = "SELECT s.*";
		$sql.= " FROM tblRegistrosApp s";
		$sql.= " WHERE s.IdUsuario = " . DB::Number($oUsuario->IdUsuario);
		$sql.= ($filter) ? $this->ParseFilter($filter) : "";

		if ( !($oRes = $this->GetQuery($sql)) )
			return false;
					
		while ($oRow = $oRes->GetRow())	
		{	
			$oRegistroApp = new RegistroApp();
			$oRegistroApp->ParseFromArray($oRow);
			
			array_push($arr, $oRegistroApp);
			
			$oRes->MoveNext();
		}

		return $arr;
	}
	

	public function GetById($IdRegistro)
	{
		$sql = "SELECT s.*";
		$sql.= " FROM tblRegistrosApp s";
		$sql.= " WHERE IdRegistro = " . DB::Number($IdRegistro);	

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

	
	public function GetCountRows(array $filter = NULL)
	{
		$sql = "SELECT s.*";
		$sql.= " FROM tblRegistrosApp s";
		$sql.= " INNER JOIN tblUsuarios u ON s.IdUsuario = u.IdUsuario";
		$sql.= " WHERE CodigoRegistro <> 'BLACKLISTED'";
		$sql.= ($filter) ? $this->ParseFilter($filter) : "";
		$sql.= " GROUP BY CodigoRegistro";

		if (!($oRes = $this->GetQuery($sql)))
			return false;
		
		$CountRows = $oRes->NumRows();
		
		return $CountRows;
	}
	
	
	public function Create(RegistroApp $oRegistroApp)
	{
		$arr = array
		(
			'IdUsuario' 		=> DB::Number($oRegistroApp->IdUsuario),
			'Plataforma'		=> DB::String($oRegistroApp->Plataforma),
			'Email'				=> DB::String($oRegistroApp->Email),
			'CodigoRegistro'	=> DB::String($oRegistroApp->CodigoRegistro)
		);
		
		if (!$this->Insert('tblRegistrosApp', $arr))
			return false;
			
		$oRegistroApp->IdRegistro = DBAccess::GetLastInsertId();
			
		return $oRegistroApp;
	}
	
	
	public function Update(RegistroApp $oRegistroApp)
	{
		$where = " IdRegistro = " . DB::Number($oRegistroApp->IdRegistro);
		
		$arr = array
		(
			'IdUsuario' 	=> DB::Number($oRegistroApp->IdUsuario),
			'Plataforma'		=> DB::String($oRegistroApp->Plataforma),
			'Email'				=> DB::String($oRegistroApp->Email),
			'CodigoRegistro'	=> DB::String($oRegistroApp->CodigoRegistro)
		);
		
		if (!DBAccess::UpdateEntidad('tblRegistrosApp', $arr, $where))
			return false;
		
		return $oRegistroApp;
	}


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

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

?>

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