<?php
class Rol extends Conectar
{
    public function get_rol()
    {
        $conectar = parent::conexion();
        parent::set_names();
        $sql = "SELECT * FROM rol";
        $stmt = $conectar->prepare($sql);
        $stmt->execute();
        return $stmt->fetchAll();
    }

    public function get_rol_id($N_rolID)
    {
        $conectar = parent::conexion();
        parent::set_names();
        $sql = "SELECT * FROM rol WHERE N_rolID = ?";
        $stmt = $conectar->prepare($sql);
        $stmt->execute([$N_rolID]);
        return $stmt->fetch();
    }

    public function insert_rol($Sdescrip, $Cest_rol)
    {
        $conectar = parent::conexion();
        parent::set_names();
        $sql = "INSERT INTO rol (Sdescrip, Cest_rol) VALUES (?, ?)";
        $stmt = $conectar->prepare($sql);
        $stmt->execute([$Sdescrip, $Cest_rol]);
        return true;
    }

    public function update_rol($N_rolID, $Sdescrip, $Cest_rol)
    {
        $conectar = parent::conexion();
        parent::set_names();
        $sql = "UPDATE rol SET Sdescrip = ?, Cest_rol = ? WHERE N_rolID = ?";
        $stmt = $conectar->prepare($sql);
        $stmt->execute([$Sdescrip, $Cest_rol, $N_rolID]);
        return true;
    }
}
?>
