Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Utiles{
- private $id;
- private $tipo;
- private $precio;
- private $fechaCreacion;
- //constructor
- public function __construct($tipo = null, $precio = null, $fechaCreacion = null){
- if($tipo != null && $precio != null && $fechaCreacion != null):
- $this->tipo = $tipo;
- $this->precio = $precio;
- $this->fechaCreacion = $fechaCreacion;
- $this->newUtiles();
- endif;
- }
- public function getId(){
- return $this->id;
- }
- /****CAMPO tipo*****/
- public function getTipo(){
- return $this->tipo;
- }
- public function setTipo($data){
- $info = array('tipo', $this->id, 'id', 'utiles');
- Guardian::runSetSql($data, $info);
- $this->tipo = $data;
- return $this->tipo;
- }
- /**********CAMPO precio**********/
- public function getPrecio(){
- return $this->precio;
- }
- public function setPrecio($data){
- $info = array('precio', $this->id, 'id', 'utiles');
- Guardian::runSetSql($data, $info);
- $this->precio = $data;
- return $this->precio;
- }
- /**********CAMPO fechaCreacion**********/
- public function getFechaCreacion(){
- return $this->fechaCreacion;
- }
- public function setFechaCreacion($data){
- $info = array('fecha_creacion', $this->id, 'id', 'utiles');
- Guardian::runSetSql($data, $info);
- $this->fechaCreacion = $data;
- return $this->fechaCreacion;
- }
- /*******GENERALES********/
- public function getAll(){
- $dataAll = array('id' => $this->id, 'tipo' => $this->tipo, 'precio' => $this->precio, 'fechaCreacion' => $this->fechaCreacion);
- return $dataAll;
- }
- public function recoveryAll($data){
- $this->id = $data;
- $info = array('utiles', $this->id, 'id');
- $responseRecovery = Guardian::runGetAll($info);
- if($responseRecovery != null){
- $this->id = $responseRecovery['id'];
- $this->tipo = $responseRecovery['tipo'];
- $this->precio = $responseRecovery['precio'];
- $this->fechaCreacion = $responseRecovery['fecha_creacion'];
- echo "<br>Dato 'id' recuperado = ".$this->id."<br>";
- echo "<br>Dato 'tipo' recuperado = ".$this->tipo."<br>";
- echo "<br>Dato 'precio' recuperado = ".$this->precio."<br>";
- echo "<br>Dato 'fecha_creacion' recuperado = ".$this->fechaCreacion."<br>";
- }else{
- echo "<br>No se pudo inicilizar entidad con dato existente<br>";
- }
- }
- public function deleteAll(){
- $info = array('utiles', 'id');
- Guardian::runDelSql($this->id, $info);
- $this->id = null;
- $this->tipo = null;
- $this->precio = null;
- $this->fechaCreacion = null;
- return "success delete";
- }
- /*****CREATE NEW OBJETO********/
- public function newUtiles($info = array('tipo', 'precio', 'fecha_creacion', 'utiles')){
- $dataResponse = Guardian::newInsertSql($this->tipo, $this->precio, $this->fechaCreacion, $info);
- if($dataResponse != null || !empty($dataResponse)){
- $this->id = $dataResponse['id'];
- $this->tipo = $dataResponse['tipo'];
- $this->precio = $dataResponse['precio'];
- $this->fechaCreacion = $dataResponse['fecha_creacion'];
- $responseForUser = array(
- 'status' => 'Correcto',
- 'msj' => 'Dato creado de manera correcta',
- 'content' => $dataResponse
- );
- }else{
- $responseForUser = array(
- 'status' => 'Error',
- 'msj' => 'No se pudo guardar en la base de datos la información',
- 'content' => 'Fail Content'
- );
- }
- }
- }
- ?>
Add Comment
Please, Sign In to add comment