[#] hm X_Shell Backd00r [#]

Current Path : /var/www/clients/client35/web46/web/admin/models/
Upload File :
Current File : /var/www/clients/client35/web46/web/admin/models/Eventos.php

<?php


require_once 'Conexion.php';

class Eventos {

    private $id_fecha;
    private $fecha_evento;
    private $img_event;
    private $descripcion_event;
    private $nota;

    const TABLA = 'fechas_eventos';
    
    public function __construct($id_fecha=null, $fecha_evento=null, $img_event=null, $descripcion_event=null, $nota=null) {
        $this->id_fecha = $id_fecha;
        $this->fecha_evento = $fecha_evento; 
        $this->img_event = $img_event;
        $this->descripcion_event = $descripcion_event;
        $this->nota = $nota;
    }

    public function getid_fecha() {
        return $this->id_fecha;
    }

    public function getfecha_evento() {
        return $this->fecha_evento;
    }

    public function getimg_event() {
        return $this->img_event;
    }
    public function getdescripcion_event() {
        return $this->descripcion_event;
    }
    public function getnota(){
        return $this->nota;
    }
    public function setId_fecha($id_fecha) {
        $this->id_fecha = $id_fecha;
    }
    public function setFecha_evento($fecha_evento) {
        $this->fecha_evento = $fecha_evento;
    }

    public function setImg_event($img_event) {
        $this->img_event = $img_event;
    }
      public function setDescripcion_event($descripcion_event) {
        $this->descripcion_event = $descripcion_event;
    }
     public function setNota($nota) {
        $this->nota = $nota;
    }

      public function guardar() {
        $conexion = new Conexion();
        $consulta = $conexion->prepare('INSERT INTO ' . self::TABLA . ' (fecha_evento, img_event, descripcion_event, nota) VALUES(:fecha_evento, :img_event, :descripcion_event, :nota)');
        $consulta->bindParam(':fecha_evento', $this->fecha_evento);
        $consulta->bindParam(':img_event', $this->img_event);
        $consulta->bindParam(':descripcion_event', $this->descripcion_event);
        $consulta->bindParam(':nota', $this->nota);
        $consulta->execute();
        $conexion = null; 
                              }


    public function Actualizar() {
        $conexion = new Conexion();
        $consulta = $conexion->prepare('UPDATE ' . self::TABLA . ' SET fecha_evento = :fecha_evento, descripcion_event = :descripcion_event, nota = :nota  WHERE id_fecha = :id_fecha');
        $consulta->bindParam(':id_fecha', $this->id_fecha);
        $consulta->bindParam(':fecha_evento', $this->fecha_evento);
        $consulta->bindParam(':descripcion_event', $this->descripcion_event);
        $consulta->bindParam(':nota', $this->nota);
        $consulta->execute();
        $conexion = null;
                               }

     public function Actualizar2() {
        $conexion = new Conexion();
        $consulta = $conexion->prepare('UPDATE ' . self::TABLA . ' SET fecha_evento = :fecha_evento, img_event = :img_event, descripcion_event = :descripcion_event, nota = :nota  WHERE id_fecha = :id_fecha');
        $consulta->bindParam(':id_fecha', $this->id_fecha);
        $consulta->bindParam(':img_event', $this->img_event);
        $consulta->bindParam(':fecha_evento', $this->fecha_evento);
        $consulta->bindParam(':descripcion_event', $this->descripcion_event);
        $consulta->bindParam(':nota', $this->nota);
        $consulta->execute();
        $conexion = null;
                               }

  

    
    public function eliminar($id_fecha){
        $conexion = new Conexion();
        $consulta = $conexion->prepare('DELETE FROM ' . self::TABLA . ' WHERE id_fecha = :id_fecha');
        $consulta->bindParam(':id_fecha', $id_fecha);
        $consulta->execute();
        $conexion = null;
    }

    public static function buscarPorid_fecha($id_fecha) {
        $conexion = new Conexion();
        $consulta = $conexion->prepare('SELECT fecha_evento, img_event FROM ' . self::TABLA . ' WHERE id_fecha = :id_fecha');
        $consulta->bindParam(':id_fecha', $id_fecha);
        $consulta->execute();
        $registro = $consulta->fetch();
        $conexion = null;
        if ($registro) {
            return new self($registro['fecha_evento'], $registro['img_event'], $id_fecha);
        } else {
            return false;
        }
    }

    public static function verEventos() {
        $conexion = new Conexion();
        $consulta = $conexion->prepare('SELECT id_fecha, fecha_evento, img_event, descripcion_event, nota FROM fechas_eventos ORDER BY fecha_evento DESC');
        $consulta->execute();
        $registros = $consulta->fetchAll();
        $conexion = null;
        return $registros;
    }

public static function ultimo_id() {
        $conexion = new Conexion();
        $consulta = $conexion->prepare('SELECT MAX(id_fecha) AS id_fecha FROM fechas_eventos');
        $consulta->execute();
        $registros = $consulta->fetchAll();
        $conexion = null;
        return $registros;
    }
        


}

Mr.hm X_Shell Backd00r 1.0, Coded By Mr.hm X_Shell Backd00r