Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace models;
- use PDO;
- class Conexion{
- private $host = "localhost";
- private $user = "root";
- private $pass = "";
- private $dbname = "veterinaria";
- private $charset = "utf8";
- private $port = 3306;
- private $conexion = null;
- public function __construct()
- {
- try {
- $dsn = "mysql:host={$this->host};dbname={$this->dbname};charset={$this->charset};port={$this->port}";
- $this->conexion = new PDO($dsn, $this->user, $this->pass, array(
- PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
- PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
- PDO::ATTR_EMULATE_PREPARES => FALSE
- ));
- } catch (PDOException $ex) {
- print $ex->getMessage();
- print $ex->getCode();
- print_r($ex->getTrace());
- print $ex->getLine();
- }
- }
- namespace models;
- use PDO;
- require('Conexion.php');
- class Paciente{
- private $id_paciente;
- private $fk_tipo;
- private $nombre;
- private $edad;
- private $foto;
- private $c_vacunacion;
- private $fk_dueño;
- private $peso;
- private $conexion;
- public function __construct()
- {
- $this->conexion = new Conexion();
- }
- public function retornarPaciente(int $id_paciente):array
- {
- $sql = "SELECT id_paciente, nombre, edad, foto, peso FROM paciente WHERE id_paciente = :id";
- $stmn = $this->conexion->get()->prepare($sql);
- $stmn->bindParam(":id", $id_paciente, PDO::PARAM_INT);
- $stmn->execute();
- return $stmn->fetch();
- }
Add Comment
Please, Sign In to add comment