Mister Spy Say ="Hello Kids ... :D"
___ ____ _ _____
| \/ (_) | | / ___|
| . . |_ ___| |_ ___ _ __ \ `--. _ __ _ _
| |\/| | / __| __/ _ \ '__| `--. \ '_ \| | | |
| | | | \__ \ || __/ | /\__/ / |_) | |_| |
\_| |_/_|___/\__\___|_| \____/| .__/ \__, |
| | __/ |
|_| |___/
Bot Mister Spy V3
Mister Spy
Mister Spy
<?php
require_once('class.dbaccess.php');
require_once('class.socio.php');
require_once('class.filter.php');
require_once('class.page.php');
class Socios extends DBAccess implements IFilterable
{
public function ParseFilter(array $filter)
{
$sql = '';
if (isset($filter['Nombre']))
{
$sql.= " AND ( Nombre LIKE '%" . DB::StringUnquoted($filter['Nombre']) . "%'";
$sql.= " OR Nombre IS NULL)";
}
if (isset($filter['NumeroSocio']))
{
$sql.= " AND ( NumeroSocio LIKE '%" . DB::StringUnquoted($filter['NumeroSocio']) . "%'";
$sql.= " OR NumeroSocio IS NULL)";
}
return $sql;
}
public function GetPagesCount(Page $oPage, array $filter = NULL)
{
$Count = $this->GetCountRows($filter);
$Count = $Count / $oPage->Size;
return ceil($Count);
}
public function GetAll(array $filter = NULL, Page $oPage = NULL)
{
$sql = "SELECT *";
$sql.= " FROM tblSociosAccc";
$sql.= " WHERE 1";
if ($filter)
$sql.= $this->ParseFilter($filter);
if ($oPage != NULL)
$sql.= " " . Pageable::ParsePage($oPage);
if (!($oRes = $this->GetQuery($sql)))
return false;
$arr = array();
while ($oRow = $oRes->GetRow())
{
$oSocio = new Socio();
$oSocio->ParseFromArray($oRow);
array_push($arr, $oSocio);
$oRes->MoveNext();
}
return $arr;
}
public function GetById($IdSocio)
{
$sql = "SELECT *";
$sql.= " FROM tblSociosAccc";
$sql.= " WHERE IdSocio = " . DB::Number($IdSocio);
if (!($oRes = $this->GetQuery($sql)))
return false;
if (!($oRow = $oRes->GetRow()))
return false;
$oSocio = new Socio();
$oSocio->ParseFromArray($oRow);
return $oSocio;
}
public function GetCountRows(array $filter = NULL)
{
$sql = "SELECT *";
$sql.= " FROM tblSociosAccc";
$sql.= " WHERE 1";
if ($filter)
$sql.= $this->ParseFilter($filter);
$sql.= " GROUP BY IdSocio";
$sql.= " ORDER BY Nombre";
if (!($oRes = $this->GetQuery($sql)))
return false;
$CountRows = $oRes->NumRows();
return $CountRows;
}
public function GetByNumeroSocio($NumeroSocio)
{
$sql = "SELECT *";
$sql.= " FROM tblSociosAccc";
$sql.= " WHERE NumeroSocio = " . DB::String($NumeroSocio);
if (!($oRes = $this->GetQuery($sql)))
return false;
if (!($oRow = $oRes->GetRow()))
return false;
$oSocio = new Socio();
$oSocio->ParseFromArray($oRow);
return $oSocio;
}
public function Create(Socio $oSocio)
{
$arr = array(
'Nombre' => DB::String($oSocio->Nombre),
'NumeroSocio' => DB::String($oSocio->NumeroSocio),
'TipoSocio' => DB::String($oSocio->TipoSocio)
);
if (!$this->Insert('tblSociosAccc', $arr))
return false;
$oSocio->IdSocio = DBAccess::GetLastInsertId();
return $oSocio;
}
public function Update(Socio $oSocio)
{
$where = " IdSocio = " . DB::Number($oSocio->IdSocio);
$arr = array(
'Nombre' => DB::String($oSocio->Nombre),
'NumeroSocio' => DB::String($oSocio->NumeroSocio),
'TipoSocio' => DB::String($oSocio->TipoSocio)
);
if (!DBAccess::Update('tblSociosAccc', $arr, $where))
return false;
return $oSocio;
}
public function Delete($IdSocio)
{
if (!DBAccess::$db->Begin())
return false;
$where = " IdSocio = " . DB::Number($IdSocio);
if (!DBAccess::Delete('tblSociosAccc', $where))
{
DBAccess::$db->Rollback();
return false;
}
$where = " IdSocioAccc = " . DB::Number($IdSocio);
if (!DBAccess::Delete('tblSociosAcccPropietarios', $where))
{
DBAccess::$db->Rollback();
return false;
}
DBAccess::$db->Commit();
return true;
}
}
?>
Mr. DellatioNx196 GaLers xh3LL Backd00r 1.0, Coded By Mr. DellatioNx196 - Bogor BlackHat