Guest User

Untitled

a guest
Jan 6th, 2019
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. namespace models;
  2. use PDO;
  3. class Conexion{
  4. private $host = "localhost";
  5. private $user = "root";
  6. private $pass = "";
  7. private $dbname = "veterinaria";
  8. private $charset = "utf8";
  9. private $port = 3306;
  10. private $conexion = null;
  11.  
  12. public function __construct()
  13. {
  14. try {
  15. $dsn = "mysql:host={$this->host};dbname={$this->dbname};charset={$this->charset};port={$this->port}";
  16. $this->conexion = new PDO($dsn, $this->user, $this->pass, array(
  17. PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
  18. PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
  19. PDO::ATTR_EMULATE_PREPARES => FALSE
  20. ));
  21. } catch (PDOException $ex) {
  22. print $ex->getMessage();
  23. print $ex->getCode();
  24. print_r($ex->getTrace());
  25. print $ex->getLine();
  26. }
  27. }
  28.  
  29. namespace models;
  30. use PDO;
  31. require('Conexion.php');
  32. class Paciente{
  33. private $id_paciente;
  34. private $fk_tipo;
  35. private $nombre;
  36. private $edad;
  37. private $foto;
  38. private $c_vacunacion;
  39. private $fk_dueño;
  40. private $peso;
  41. private $conexion;
  42.  
  43. public function __construct()
  44. {
  45. $this->conexion = new Conexion();
  46. }
  47.  
  48. public function retornarPaciente(int $id_paciente):array
  49. {
  50. $sql = "SELECT id_paciente, nombre, edad, foto, peso FROM paciente WHERE id_paciente = :id";
  51. $stmn = $this->conexion->get()->prepare($sql);
  52. $stmn->bindParam(":id", $id_paciente, PDO::PARAM_INT);
  53. $stmn->execute();
  54. return $stmn->fetch();
  55. }
Add Comment
Please, Sign In to add comment