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 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"); $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; } } ?>