Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created July 5, 2019 16:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/09b56cc8af332ce43eae8faac815bd2f to your computer and use it in GitHub Desktop.
Save parzibyte/09b56cc8af332ce43eae8faac815bd2f to your computer and use it in GitHub Desktop.
<?php
class ProductoModel extends CI_Model{
public $id;
public $codigo;
public $descripcion;
public $precioVenta;
public $precioCompra;
public $existencia;
public function __construct(){
$this->load->database();
}
public function nuevo($codigo, $descripcion, $precioVenta, $precioCompra, $existencia){
$this->codigo = $codigo;
$this->descripcion = $descripcion;
$this->precioVenta = $precioVenta;
$this->precioCompra = $precioCompra;
$this->existencia = $existencia;
return $this->db->insert('productos', $this);
}
public function guardarCambios($id, $codigo, $descripcion, $precioVenta, $precioCompra, $existencia){
$this->id = $id;
$this->codigo = $codigo;
$this->descripcion = $descripcion;
$this->precioVenta = $precioVenta;
$this->precioCompra = $precioCompra;
$this->existencia = $existencia;
return $this->db->update('productos', $this, array("id" => $id));
}
public function todos(){
return $this->db->get("productos")->result();
}
public function eliminar($id){
return $this->db->delete("productos", array("id" => $id));
}
public function uno($id){
return $this->db->get_where("productos", array("id" => $id))->row();
}
public function porCodigoDeBarras($codigoDeBarras){
return $this->db->get_where("productos", array("codigo" => $codigoDeBarras))->row();
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment