initial commit

This commit is contained in:
Daniel Cortés
2019-12-12 16:05:20 -03:00
commit f480b2942f
13 changed files with 444 additions and 0 deletions

46
models/alumno.php Normal file
View File

@@ -0,0 +1,46 @@
<?php
require_once('../db.php');
class Alumno
{
private $id;
private $rut;
private $nombre;
public function __construct() {}
public function set_id($id) { $this->id = $id; }
public function get_id() { return $this->id; }
public function set_rut($rut) { $this->rut = $rut; }
public function get_rut() { return $this->rut; }
public function set_nombre($nombre) { $this->nombre = $nombre; }
public function get_nombre() { return $this->nombre; }
public function save()
{
$db = new DB();
$result = $db->dml
(
"insert into alumno (rut, nombre) values (?, ?)",
$this->rut, $this->nombre
);
return $result > 0;
}
public static function getAll() {
$db = new DB();
$results = $db->query("select * from alumno");
$alumnos = [];
foreach($results as $result) {
$alumno = new Alumno();
$alumno->set_id($result['id']);
$alumno->set_rut($result['rut']);
$alumno->set_nombre($result['nombre']);
array_push($alumnos, $alumno);
}
return $alumnos;
}
}
?>