| Server IP : 217.160.0.64 / Your IP : 216.73.216.91 Web Server : Apache System : Linux info 3.0 #1337 SMP Tue Jan 01 00:00:00 CEST 2000 all GNU/Linux User : ws67269618 ( 67269618) PHP Version : 8.4.28 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /homepages/36/d4298801080/htdocs/gastrobar/app/admin/db/ |
Upload File : |
<?php
require_once('MysqliDb.php');
class DatosModulos {
private $database;
private $tabla;
// CAMPOS
private $id_modulo;
private $nombre;
private $clave_mto;
private $imagen;
private $gestion;
// Constructor
public function __construct() {
require_once('config.php');
$this->database = new MysqliDb(DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE);
$this->tabla = TABLA_MODULOS;
}
public function getId_modulo() {
return $this->id_modulo;
}
public function getNombre() {
return $this->nombre;
}
public function getClave_mto() {
return $this->clave_mto;
}
public function getImagen() {
return $this->imagen;
}
public function getGestion() {
return $this->gestion;
}
public function setId_modulo( $val ) {
$this->id_modulo = $val;
}
public function setNombre( $val ) {
$this->nombre = $val;
}
public function setClave_mto( $val ) {
$this->clave_mto = $val;
}
public function setImagen( $val ) {
$this->imagen = $val;
}
public function setGestion( $val ) {
$this->gestion = $val;
}
private function asignarCamposSelect($registro) {
$this->id_modulo = $registro["id_modulo"];
$this->nombre = $registro["nombre"];
$this->clave_mto = $registro["clave_mto"];
$this->imagen = $registro["imagen"];
$this->gestion = $registro["gestion"];
}
public function select( $id_modulo ) {
$this->database->where("id_modulo", $id_modulo);
$registro = $this->database->getOne($this->tabla);
$this->asignarCamposSelect($registro);
}
public function selectPorNombre( $nombre ) {
$this->database->where("nombre", $nombre);
$registro = $this->database->getOne($this->tabla);
$this->asignarCamposSelect($registro);
}
public function selectPorClave_mto( $clave_mto ) {
$this->database->where("clave_mto", $clave_mto);
$registro = $this->database->getOne($this->tabla);
$this->asignarCamposSelect($registro);
}
public function listAll($nombre) {
if(isset($nombre)) {
$this->database->where("nombre", $nombre);
}
$this->database->orderBy("clave_mto", "asc");
$salida = $this->database->get($this->tabla);
$dataset = [];
$i=0;
foreach ($salida as $registro) {
$dataset[$i]["id_modulo"] = $registro["id_modulo"];
$dataset[$i]["nombre"] = $registro["nombre"];
$dataset[$i]["clave_mto"] = $registro["clave_mto"];
$dataset[$i]["imagen"] = $registro["imagen"];
$dataset[$i]["gestion"] = $registro["gestion"];
$i++;
}
return $dataset;
}
public function listadoMto($nombre) {
if(isset($nombre)) {
$this->database->where("nombre", $nombre);
}
$this->database->orderBy("clave_mto", "asc");
$salida = $this->database->get($this->tabla);
$dataset = [];
foreach ($salida as $registro) {
$dataset[] = [
"id_modulo" => $registro["id_modulo"],
"nombre" => $registro["nombre"],
"clave_mto" => $registro["clave_mto"],
"imagen" => $registro["imagen"],
"gestion" => $registro["gestion"]
];
}
return $dataset;
}
public function insert() {
$this->id_modulo = NULL; // clear key for autoincrement
$data = Array ("nombre" => $this->nombre,
"clave_mto" => $this->clave_mto,
"imagen" => $this->imagen,
"gestion" => $this->gestion
);
$this->id_modulo = $this->database->insert ($this->tabla, $data);
}
public function update( $id_modulo ) {
$data = Array ("nombre" => $this->nombre,
"clave_mto" => $this->clave_mto,
"imagen" => $this->imagen,
"gestion" => $this->gestion
);
$this->database->where("id_modulo", $id_modulo);
return $this->database->update($this->tabla, $data);
}
public function delete( $id_modulo ) {
$this->database->where("id_modulo", $id_modulo);
return $this->database->delete($this->tabla);
}
public function getLastError() {
return $this->database->getLastError();
}
}
?>