Mister Spy Say ="Hello Kids ... :D"
___ ____ _ _____
| \/ (_) | | / ___|
| . . |_ ___| |_ ___ _ __ \ `--. _ __ _ _
| |\/| | / __| __/ _ \ '__| `--. \ '_ \| | | |
| | | | \__ \ || __/ | /\__/ / |_) | |_| |
\_| |_/_|___/\__\___|_| \____/| .__/ \__, |
| | __/ |
|_| |___/
Bot Mister Spy V3
Mister Spy
Mister Spy
<?php
require_once('class.dbaccess.php');
require_once('class.contacto.php');
require_once('class.filter.php');
require_once('class.page.php');
class Contactos extends DBAccess implements IFilterable
{
public function ParseFilter(array $filter)
{
if ((isset($filter['Destino'])) && ($filter['Destino'] != ''))
$sql.= " AND e.Destino LIKE '%" . DB::StringUnquoted($filter['Destino']) . "%'";
if ((isset($filter['Nombre'])) && ($filter['Nombre'] != ''))
$sql.= " AND e.Nombre LIKE '%" . DB::StringUnquoted($filter['Nombre']) . "%'";
if ((isset($filter['Email'])) && ($filter['Email'] != ''))
$sql.= " AND e.Email LIKE '%" . DB::StringUnquoted($filter['Email']) . "%'";
if ((isset($filter['Fecha'])) && ($filter['Fecha'] != '')) {
$sql.= " AND (e.Fecha >= " . DB::Date($filter['Fecha']);
$sql.= " AND e.Fecha <= " . DB::Date($filter['Fecha'] . ' 23:59:59') . ')';
}
return $sql;
}
public function GetAll(array $filter = NULL, Page $oPage = NULL)
{
$sql = "SELECT e.*";
$sql.= " FROM tblContactos e";
$sql.= " WHERE 1";
$sql.= ($filter) ? $this->ParseFilter($filter) : "";
$sql.= " ORDER BY e.Fecha DESC";
$sql.= ($oPage) ? Pageable::ParsePage($oPage) : "";
if (!($oRes = $this->GetQuery($sql)))
return false;
$arr = array();
while ($oRow = $oRes->GetRow())
{
$oContacto = new Contacto();
$oContacto->ParseFromArray($oRow);
array_push($arr, $oContacto);
$oRes->MoveNext();
}
return $arr;
}
public function GetById($IdContacto)
{
$sql = "SELECT e.*";
$sql.= " FROM tblContactos e";
$sql.= " WHERE e.IdContacto = " . DB::Number($IdContacto);
if (!($oRes = $this->GetQuery($sql)))
return false;
if (!($oRow = $oRes->GetRow()))
return false;
$oContacto = new Contacto();
$oContacto->ParseFromArray($oRow);
return $oContacto;
}
public function GetCountRows(array $filter = NULL)
{
$sql = "SELECT e.* ";
$sql.= " FROM tblContactos e";
$sql.= " WHERE 1";
$sql.= ($filter) ? $this->ParseFilter($filter) : "";
$sql.= " GROUP BY e.IdContacto";
if (!($oRes = $this->GetQuery($sql)))
return false;
$CountRows = $oRes->NumRows();
return $CountRows;
}
public function Create(Contacto $oContacto)
{
$arr = array
(
'Destino' => DB::String($oContacto->Destino),
'Nombre' => DB::String($oContacto->Nombre),
'Fecha' => DB::Date($oContacto->Fecha),
'Email' => DB::String($oContacto->Email),
'Telefono' => DB::String($oContacto->Telefono),
'Consulta' => DB::String($oContacto->Consulta)
);
if (!$this->Insert('tblContactos', $arr))
return false;
$oContacto->IdContacto = DBAccess::GetLastInsertId();
return $oContacto;
}
public function Update(Contacto $oContacto)
{
$where = " IdContacto = " . DB::Number($oContacto->IdContacto);
$arr = array
(
'Destino' => DB::String($oContacto->Destino),
'Nombre' => DB::String($oContacto->Nombre),
'Fecha' => DB::Date($oContacto->Fecha),
'Email' => DB::String($oContacto->Email),
'Telefono' => DB::String($oContacto->Telefono),
'Consulta' => DB::String($oContacto->Consulta)
);
if (!DBAccess::UpdateEntidad('tblContactos', $arr, $where))
return false;
return $oContacto;
}
public function Delete($IdContacto)
{
if (!DBAccess::$db->Begin())
return false;
$where = " IdContacto = " . DB::Number($IdContacto);
if (!DBAccess::DeleteEntidad('tblContactos', $where))
{
DBAccess::$db->Rollback();
return false;
}
DBAccess::$db->Commit();
return true;
}
}
?>
Mr. DellatioNx196 GaLers xh3LL Backd00r 1.0, Coded By Mr. DellatioNx196 - Bogor BlackHat