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