This commit is contained in:
Daniel Cortés
2019-12-13 13:53:12 -03:00
parent f480b2942f
commit fdada2adcc
14 changed files with 220 additions and 132 deletions

View File

@@ -28,6 +28,37 @@ class Alumno
return $result > 0;
}
public function update()
{
$db = new DB();
$result = $db->dml(
"update alumno set rut = ?, nombre = ? where id = ?",
$this->rut, $this->nombre, $this->id
);
return $result > 0;
}
public static function delete($id) {
$db = new DB();
error_log("id: $id");
$result = $db->dml("delete from alumno where id = ?", $id);
return $result > 0;
}
public static function get($id) {
$db = new DB();
$results = $db->query("select * from alumno where id = ?", $id);
foreach($results as $result) {
$alumno = new Alumno();
$alumno->set_id($result['id']);
$alumno->set_rut($result['rut']);
$alumno->set_nombre($result['nombre']);
}
return $alumno;
}
public static function getAll() {
$db = new DB();
$results = $db->query("select * from alumno");