-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass.alumno.php
More file actions
34 lines (29 loc) · 862 Bytes
/
Copy pathclass.alumno.php
File metadata and controls
34 lines (29 loc) · 862 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
require_once('class.db.php');
class alumno {
public $conn;
private $id;
private $dni;
private $nombre;
public function __construct(int $id=0, String $dni="", String $nombre="") {
$this->conn = new db();
$this->id = $id;
$this->dni = $dni;
$this->nombre = $nombre;
}
public function obtenerAlumnos() {
$consulta = "SELECT * FROM alumnos";
$sentencia = $this->conn->getConn()->prepare($consulta);
$sentencia->execute();
$sentencia->bind_result($this->id, $this->dni, $this->nombre);
$alumnos = array();
while ($sentencia->fetch()) {
$alumnos[] = array(
"id" => $this->id,
"dni" => $this->dni,
"nombre" => $this->nombre
);
}
return $alumnos;
}
}