Viewing file: NoticiaCtrl.php (2.02 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
require_once("BaseController.php");
class NoticiaCtrl extends GenericCtrl {
var $model = "Noticia";
/**
* Construtor principal
* Inicia a classe principal de controle informando o Modelo Atual
*/
public function __construct() {
parent::setConnection($this->model);
}
public function getNoticiasDestaque($limit=1) {
$q = Doctrine_Query::create()->from("Noticia n");
$q->where("n.imagem != ''", "");
$q->addWhere("n.exibirCapa = 'S'", 'S');
$q->orderBy('not_data DESC');
$q->limit($limit);
return $q->fetchArray();
}
public function getNoticias($tipo='', $arrayIds='', $limit=false, $offset=false, $count = false) {
$q = Doctrine_Query::create()->from("Noticia n");
$q->where("n.dataExpiracao >= '".date("Y-m-d")."' OR n.dataExpiracao = '0000-00-00'");
$q->addWhere("n.acessoRestrito is null OR n.acessoRestrito = '' OR n.acessoRestrito = 'N'");
if($arrayIds != ''){
$q->andWhereNotIn('n.id',$arrayIds);
}
if($tipo == "imprensa"){
$q->addWhere("n.imprensa = ?", "S");
}
if($tipo == "capa"){
$q->addWhere("n.exibirCapa = ?", "S");
}
if($limit){
$q->limit($limit);
}
if($offset){
$q->offset($offset);
}
$q->orderBy('notdata desc');
if($count){
return $q->count();
}else{
return $q->fetchArray();
}
}
public function getNoticiasImprensa($limit=1, $offset=0, $count=false) {
$q = Doctrine_Query::create()->from("Noticia n");
$q->where("n.imprensa = ?", "S");
$q->addWhere("n.dataExpiracao >= ?", date("Y-m-d"));
$q->limit($limit);
$q->offset($offset);
$q->orderBy('notdata DESC');
if($count){
return $q->count();
}else{
return $q->fetchArray();
}
}
}
?>
|