Viewing file: EventoCtrl.php (1.88 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
require_once("BaseController.php");
class EventoCtrl extends GenericCtrl {
var $model = "Evento";
/**
* Construtor principal
* Inicia a classe principal de controle informando o Modelo Atual
*/
public function __construct() {
parent::setConnection($this->model);
}
public function getEventosComFoto($limit=1) {
$q = Doctrine_Query::create()->from("Evento e");
$q->where("e.imagem != ?", "");
$q->addWhere("e.exibir = 1");
$q->limit($limit);
$q->orderBy('dtEvento DESC');
return $q->fetchArray();
}
public function getAgendaFutura() {
$q = Doctrine_Query::create()->from("Agenda a");
$q->where("a.agdata >= ?", date("Y-m-d"));
$q->addWhere("e.exibir = 1");
$q->orderBy('agdata');
return $q->fetchArray();
}
public function getEventosFuturos($tipo = "") {
$q = Doctrine_Query::create()->from("Evento e");
$q->where("e.dataIni >= ?", date("Y-m-d"));
if (!empty($tipo)) {
$q->addWhere("e.tipo = ?", $tipo);
}
$q->addWhere("e.exibir = 1");
$q->orderBy('dataIni ASC');
return $q->fetchArray();
}
public function getEventosPassados($tipo = "") {
$q = Doctrine_Query::create()->from("Evento e");
$q->where("e.dataIni < ?", date("Y-m-d"));
if (!empty($tipo)) {
$q->addWhere("e.tipo = ?", $tipo);
}
$q->addWhere("e.exibir = 1");
$q->orderBy('dataIni DESC');
return $q->fetchArray();
}
public function getNumeroInscritos($evtId) {
$q = Doctrine_Query::create()->select("COUNT(*)")->from("Inscricao i");
$q->where("i.evtId = ?", $evtId);
$q->orderBy('id DESC');
return $q->count();
}
}
?>
|