Guest User

Untitled

a guest
Apr 25th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.28 KB | None | 0 0
  1. <?php
  2.  
  3. class Utiles{
  4.  
  5. private $id;
  6. private $tipo;
  7. private $precio;
  8. private $fechaCreacion;
  9.  
  10. //constructor
  11. public function __construct($tipo = null, $precio = null, $fechaCreacion = null){
  12.  
  13. if($tipo != null && $precio != null && $fechaCreacion != null):
  14. $this->tipo = $tipo;
  15. $this->precio = $precio;
  16. $this->fechaCreacion = $fechaCreacion;
  17. $this->newUtiles();
  18. endif;
  19.  
  20. }
  21.  
  22. public function getId(){
  23. return $this->id;
  24. }
  25.  
  26. /****CAMPO tipo*****/
  27. public function getTipo(){
  28. return $this->tipo;
  29. }
  30. public function setTipo($data){
  31.  
  32. $info = array('tipo', $this->id, 'id', 'utiles');
  33. Guardian::runSetSql($data, $info);
  34. $this->tipo = $data;
  35.  
  36. return $this->tipo;
  37.  
  38. }
  39.  
  40. /**********CAMPO precio**********/
  41. public function getPrecio(){
  42. return $this->precio;
  43. }
  44. public function setPrecio($data){
  45.  
  46. $info = array('precio', $this->id, 'id', 'utiles');
  47. Guardian::runSetSql($data, $info);
  48. $this->precio = $data;
  49.  
  50. return $this->precio;
  51. }
  52.  
  53. /**********CAMPO fechaCreacion**********/
  54. public function getFechaCreacion(){
  55. return $this->fechaCreacion;
  56. }
  57. public function setFechaCreacion($data){
  58.  
  59. $info = array('fecha_creacion', $this->id, 'id', 'utiles');
  60. Guardian::runSetSql($data, $info);
  61. $this->fechaCreacion = $data;
  62. return $this->fechaCreacion;
  63.  
  64. }
  65.  
  66. /*******GENERALES********/
  67. public function getAll(){
  68.  
  69. $dataAll = array('id' => $this->id, 'tipo' => $this->tipo, 'precio' => $this->precio, 'fechaCreacion' => $this->fechaCreacion);
  70. return $dataAll;
  71.  
  72. }
  73.  
  74. public function recoveryAll($data){
  75. $this->id = $data;
  76. $info = array('utiles', $this->id, 'id');
  77. $responseRecovery = Guardian::runGetAll($info);
  78.  
  79. if($responseRecovery != null){
  80.  
  81. $this->id = $responseRecovery['id'];
  82. $this->tipo = $responseRecovery['tipo'];
  83. $this->precio = $responseRecovery['precio'];
  84. $this->fechaCreacion = $responseRecovery['fecha_creacion'];
  85. echo "<br>Dato 'id' recuperado = ".$this->id."<br>";
  86. echo "<br>Dato 'tipo' recuperado = ".$this->tipo."<br>";
  87. echo "<br>Dato 'precio' recuperado = ".$this->precio."<br>";
  88. echo "<br>Dato 'fecha_creacion' recuperado = ".$this->fechaCreacion."<br>";
  89.  
  90. }else{
  91. echo "<br>No se pudo inicilizar entidad con dato existente<br>";
  92. }
  93.  
  94. }
  95.  
  96. public function deleteAll(){
  97. $info = array('utiles', 'id');
  98.  
  99. Guardian::runDelSql($this->id, $info);
  100. $this->id = null;
  101. $this->tipo = null;
  102. $this->precio = null;
  103. $this->fechaCreacion = null;
  104.  
  105. return "success delete";
  106. }
  107.  
  108. /*****CREATE NEW OBJETO********/
  109. public function newUtiles($info = array('tipo', 'precio', 'fecha_creacion', 'utiles')){
  110.  
  111. $dataResponse = Guardian::newInsertSql($this->tipo, $this->precio, $this->fechaCreacion, $info);
  112.  
  113. if($dataResponse != null || !empty($dataResponse)){
  114. $this->id = $dataResponse['id'];
  115. $this->tipo = $dataResponse['tipo'];
  116. $this->precio = $dataResponse['precio'];
  117. $this->fechaCreacion = $dataResponse['fecha_creacion'];
  118.  
  119. $responseForUser = array(
  120. 'status' => 'Correcto',
  121. 'msj' => 'Dato creado de manera correcta',
  122. 'content' => $dataResponse
  123. );
  124. }else{
  125. $responseForUser = array(
  126. 'status' => 'Error',
  127. 'msj' => 'No se pudo guardar en la base de datos la información',
  128. 'content' => 'Fail Content'
  129. );
  130. }
  131.  
  132. }
  133.  
  134. }
  135.  
  136. ?>
Add Comment
Please, Sign In to add comment