| 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 DatosEmpresas {
private $database;
private $tabla;
// CAMPOS
private $id_empresa;
private $cif;
private $nombre;
private $razon_social;
private $direccion;
private $poblacion;
private $cod_postal;
private $provincia;
private $telefono1;
private $telefono2;
private $email;
private $web;
// Constructor
public function __construct() {
require_once('config.php');
$this->database = new MysqliDb(DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE);
$this->tabla = TABLA_EMPRESAS;
}
public function getId_empresa() {
return $this->id_empresa;
}
public function getCif() {
return $this->cif;
}
public function getNombre() {
return $this->nombre;
}
public function getRazon_social() {
return $this->razon_social;
}
public function getDireccion() {
return $this->direccion;
}
public function getPoblacion() {
return $this->poblacion;
}
public function getCod_postal() {
return $this->cod_postal;
}
public function getProvincia() {
return $this->provincia;
}
public function getTelefono1() {
return $this->telefono1;
}
public function getTelefono2() {
return $this->telefono2;
}
public function getEmail() {
return $this->email;
}
public function getWeb() {
return $this->web;
}
public function setId_empresa( $val ) {
$this->id_empresa = $val;
}
public function setCif( $val ) {
$this->cif = $val;
}
public function setNombre( $val ) {
$this->nombre = $val;
}
public function setRazon_social( $val ) {
$this->razon_social = $val;
}
public function setDireccion( $val ) {
$this->direccion = $val;
}
public function setPoblacion( $val ) {
$this->poblacion = $val;
}
public function setCod_postal( $val ) {
$this->cod_postal = $val;
}
public function setProvincia( $val ) {
$this->provincia = $val;
}
public function setTelefono1( $val ) {
$this->telefono1 = $val;
}
public function setTelefono2( $val ) {
$this->telefono2 = $val;
}
public function setEmail( $val ) {
$this->email = $val;
}
public function setWeb( $val ) {
$this->web = $val;
}
private function asignarCamposSelect($registro) {
$this->id_empresa = $registro["id_empresa"];
$this->cif = $registro["cif"];
$this->nombre = $registro["nombre"];
$this->razon_social = $registro["razon_social"];
$this->direccion = $registro["direccion"];
$this->poblacion = $registro["poblacion"];
$this->cod_postal = $registro["cod_postal"];
$this->provincia = $registro["provincia"];
$this->telefono1 = $registro["telefono1"];
$this->telefono2 = $registro["telefono2"];
$this->email = $registro["email"];
$this->web = $registro["web"];
}
public function select( $id_empresa ) {
$this->database->where("id_empresa", $id_empresa);
$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 selectPorRazonSocial($razon_social) {
$this->database->where("razon_social", $razon_social);
$registro = $this->database->getOne($this->tabla);
$this->asignarCamposSelect($registro);
}
public function listAll() {
$this->database->orderBy("nombre", "asc");
$salida = $this->database->get($this->tabla);
$dataset = [];
$i=0;
foreach ($salida as $registro) {
$dataset[$i]["id_empresa"] = $registro["id_empresa"];
$dataset[$i]["cif"] = $registro["cif"];
$dataset[$i]["nombre"] = $registro["nombre"];
$dataset[$i]["razon_social"] = $registro["razon_social"];
$dataset[$i]["direccion"] = $registro["direccion"];
$dataset[$i]["poblacion"] = $registro["poblacion"];
$dataset[$i]["cod_postal"] = $registro["cod_postal"];
$dataset[$i]["provincia"] = $registro["provincia"];
$dataset[$i]["telefono1"] = $registro["telefono1"];
$dataset[$i]["telefono2"] = $registro["telefono2"];
$dataset[$i]["email"] = $registro["email"];
$dataset[$i]["web"] = $registro["web"];
$i++;
}
return $dataset;
}
public function listadoMto() {
$this->database->orderBy("nombre", "asc");
$salida = $this->database->get($this->tabla);
$dataset = [];
foreach ($salida as $registro) {
$dataset[] = [
"id_empresa" => $registro["id_empresa"],
"cif" => $registro["cif"],
"nombre" => $registro["nombre"],
"razon_social" => $registro["razon_social"],
"direccion" => $registro["direccion"],
"poblacion" => $registro["poblacion"],
"cod_postal" => $registro["cod_postal"],
"provincia" => $registro["provincia"],
"telefono1" => $registro["telefono1"],
"telefono2" => $registro["telefono2"],
"email" => $registro["email"],
"web" => $registro["web"]
];
}
return $dataset;
}
public function insert() {
$this->id_empresa = NULL; // clear key for autoincrement
$data = Array ("cif" => $this->cif,
"nombre" => $this->nombre,
"razon_social" => $this->razon_social,
"direccion" => $this->direccion,
"poblacion" => $this->poblacion,
"cod_postal" => $this->cod_postal,
"provincia" => $this->provincia,
"telefono1" => $this->telefono1,
"telefono2" => $this->telefono2,
"email" => $this->email,
"web" => $this->web
);
$this->id_empresa = $this->database->insert ($this->tabla, $data);
}
public function update( $id_empresa ) {
$data = Array ("cif" => $this->cif,
"nombre" => $this->nombre,
"razon_social" => $this->razon_social,
"direccion" => $this->direccion,
"poblacion" => $this->poblacion,
"cod_postal" => $this->cod_postal,
"provincia" => $this->provincia,
"telefono1" => $this->telefono1,
"telefono2" => $this->telefono2,
"email" => $this->email,
"web" => $this->web
);
$this->database->where("id_empresa", $id_empresa);
return $this->database->update($this->tabla, $data);
}
public function delete( $id_empresa ) {
$this->database->where("id_empresa", $id_empresa);
return $this->database->delete($this->tabla);
}
public function getLastError() {
return $this->database->getLastError();
}
}
?>