db = $db; } function getNombreMes($m) { $ar['meses'] = array('Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'); return $ar['meses'][$m-1]; } function GetFechasConNoticias() { $s = "SELECT DISTINCT( CONCAT (YEAR(fecha), '-', MONTH(fecha) ) ), YEAR(fecha) AS anio, MONTH(fecha) AS mes FROM noticias ORDER BY anio DESC, mes DESC"; $res = $this->db->get_results($s, ARRAY_A); return $res; } function GetNoticias() { $where = ''; $limit = ''; if(isset($_GET['y'])&&$_GET['y']>0) { $where = " WHERE YEAR(fecha) = ".$_GET['y']; }else{ $limit = 'LIMIT 5'; } if(isset($_GET['m'])) { $where .= " AND MONTH(fecha) = ".$_GET['m']; } if(isset($_GET['p'])) { $p = ($_GET['p']*5)-5; $limit = ' LIMIT '.$p.', 5'; } $s = "SELECT *, DATE_FORMAT(fecha, '%d/%m/%Y') as fecha2 FROM noticias ".$where." ORDER BY fecha DESC, id DESC ".$limit; $res = $this->db->get_results($s, ARRAY_A); return $res; } function NoticiasHome() { $s = "SELECT *, DATE_FORMAT(fecha, '%d/%m/%Y') as fecha2 FROM noticias ORDER BY fecha DESC, id DESC LIMIT 2"; $res = $this->db->get_results($s, ARRAY_A); return $res; } function CountNoticias() { $s = "SELECT COUNT(*) AS total FROM noticias"; $r = $this->db->get_row($s, ARRAY_A); return $r['total']; } } ?>