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

Mister Spy

Current Path : /home/caballoscriollos/public_html/web/library/
Upload File :
Current File : /home/caballoscriollos/public_html/web/library/class.registroscovid.php

<?php

require_once('class.db.php');
require_once('class.dbaccess.php');
require_once('class.registrocovid.php');
require_once('class.filter.php');
require_once('class.page.php');
require_once('class.misc.php');


class RegistrosCovid extends DBAccess implements IFilterable
{
	public function ParseFilter(array $filter)
	{
		$sql = '';
		
		if ($filter['PacientesIngresados'] != "")
		{	
			$sql.= " AND (PacientesIngresados RLIKE '" . DB::StringUnquoted($filter['PacientesIngresados']) . "'";
			$sql.= " OR PacientesIngresados IS NULL)";
        }
		
		if ($filter['InvestigadoresActivos'] != "")
		{	
			$sql.= " AND (InvestigadoresActivos RLIKE '" . DB::StringUnquoted($filter['InvestigadoresActivos']) . "'";
			$sql.= " OR InvestigadoresActivos IS NULL)";
        }
        
		if ($filter['LinkEdad'] != "")
		{	
			$sql.= " AND (LinkEdad RLIKE '" . DB::StringUnquoted($filter['LinkEdad']) . "'";
			$sql.= " OR LinkEdad IS NULL)";
        }

		if ((isset($filter['Fecha'])) && ($filter['Fecha'] != ''))
		{
			$sql.= " AND Fecha = " . DB::Date($filter['Fecha']);
		}

		if ((isset($filter['FechaDesde'])) && ($filter['FechaDesde'] != ''))
		{
			$sql.= " AND Fecha >= " . DB::Date($filter['FechaDesde']);
		}

		if ((isset($filter['FechaHasta'])) && ($filter['FechaHasta'] != ''))
		{
			$sql.= " AND Fecha <= " . DB::Date($filter['FechaHasta']);
		} 
		
		return $sql;
	}	
	

	public function GetPagesCount(Page $oPage, $filter = false)
	{	
		$CountRows = $this->GetCountRows($filter);
		$Count = $CountRows / DB::Number($oPage->Size);
		
		$Count = ceil($Count);
		
		return $Count;
	}
		
		
	public function GetAll(array $filter = NULL, Page $oPage = NULL)
	{
		if (!$oRes = $this->GetAllContent($filter, $oPage))
			return false;
			
		$arr = array();

		while ($oRow = $oRes->GetRow())	
		{	
			$oRegistroCovid = new RegistroCovid();
			$oRegistroCovid->ParseFromArray($oRow);
			
			array_push($arr, $oRegistroCovid);
			
			$oRes->MoveNext();
		}	
		
		return $arr;		
	}

	public function GetLast() {
		$sql = 'SELECT *';
		$sql.= ' FROM tblRegistrosCovid';
		$sql.= ' ORDER BY Fecha DESC';
		$sql.= ' LIMIT 1';
			
		if ( !($oRes = $this->GetQuery($sql)) )
			return false;
			
		if ( !($oRow = $oRes->GetRow()) )
			return false;
		
		$oRegistroCovid = new RegistroCovid();
		$oRegistroCovid->ParseFromArray($oRow);
		
		return $oRegistroCovid;		
	}
	
		
		
	public function GetAllContent(array $filter = NULL, Page $oPage = NULL)
	{
		$sql = " SELECT u.*";
		$sql.= " FROM tblRegistrosCovid u";
		$sql.= " WHERE 1";

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

		$sql.= " ORDER BY u.Fecha DESC";

		if ($oPage != NULL)
			$sql.= " " . Pageable::ParsePage($oPage);
			
		if ( !($oRes = $this->GetQuery($sql)) )
			return false;
			
		return $oRes;		
	}
	
	
	public function GetById($IdRegistroCovid)
	{
		$sql = "SELECT u.*";
		$sql.= " FROM tblRegistrosCovid u";
		$sql.= " WHERE u.IdRegistroCovid = " . DB::Number($IdRegistroCovid);	
			
		if ( !($oRes = $this->GetQuery($sql)) )
			return false;
			
		if ( !($oRow = $oRes->GetRow()) )
			return false;
		
		$oRegistroCovid = new RegistroCovid();
		$oRegistroCovid->ParseFromArray($oRow);
		
		return $oRegistroCovid;		
	}
	
	
	public function GetCountRows(array $filter = NULL)
	{
		$sql = " SELECT u.*";
		$sql.= " FROM tblRegistrosCovid u";
		$sql.= " WHERE 1";

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

		$sql.= " GROUP BY u.IdRegistroCovid";

		if (!($oRes = $this->GetQuery($sql)))
			return false;
		
		$CountRows = $oRes->NumRows();
		
		return $CountRows;
	}
	
	private function GetArrayDB(RegistroCovid $oRegistroCovid)
	{
		$arr = array
		(
			'Fecha'							=> DB::Date($oRegistroCovid->Fecha),
			'PacientesIngresados'			=> DB::String($oRegistroCovid->PacientesIngresados),
			'InvestigadoresActivos'			=> DB::String($oRegistroCovid->InvestigadoresActivos),
			'LinkSexo'						=> DB::String($oRegistroCovid->LinkSexo),
			'LinkEdad'						=> DB::String($oRegistroCovid->LinkEdad),
			'LinkEnfermedadesReumaticas'	=> DB::String($oRegistroCovid->LinkEnfermedadesReumaticas),
			'LinkDistribucion'				=> DB::String($oRegistroCovid->LinkDistribucion),
			'ImagenSexo'					=> DB::String($oRegistroCovid->ImagenSexo),
			'ImagenEdad'					=> DB::String($oRegistroCovid->ImagenEdad),
			'ImagenEnfermedadesReumaticas'	=> DB::String($oRegistroCovid->ImagenEnfermedadesReumaticas),
			'ImagenDistribucion'			=> DB::String($oRegistroCovid->ImagenDistribucion)
		);
		
		return $arr;
	}
	
	public function Create(RegistroCovid $oRegistroCovid)
	{
		/* inicia una transaccion */
		if (!DBAccess::$db->Begin())
			return false;
	
		$arr = $this->GetArrayDB($oRegistroCovid);

		if (!DBAccess::Insert('tblRegistrosCovid', $arr))
		{
			DBAccess::$db->Rollback();	
			return false;
		}			

		/* finaliza la transaccion */
		DBAccess::$db->Commit();

		$oRegistroCovid->IdRegistroCovid = DBAccess::GetLastInsertId();	
			
		return $oRegistroCovid;
	}
	
	
	public function Update(RegistroCovid $oRegistroCovid)
	{
		/* inicia una transaccion */
		if (!DBAccess::$db->Begin())
			return false;

		$arr = $this->GetArrayDB($oRegistroCovid);
		
		$where = " IdRegistroCovid = " . (int)$oRegistroCovid->IdRegistroCovid;

		if (!DBAccess::UpdateEntidad('tblRegistrosCovid', $arr, $where))
		{
			DBAccess::$db->Rollback();	
			return false;
		}	
		
		/* finaliza la transaccion */
		DBAccess::$db->Commit();
				
		return $oRegistroCovid;
	}
	
	
	public function Delete($IdRegistroCovid)
	{
		if (!DBAccess::$db->Begin())
			return false;
			
		$where = " IdRegistroCovid = " . DB::Number($IdRegistroCovid);
		
		if (!DBAccess::DeleteEntidad('tblRegistrosCovid', $where))
		{
				DBAccess::$db->Rollback();	
				return false;
		}		

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

?>

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