Código PHP:
class Alumno {
var $ern;
var $nombre;
var $apellido;
function __construct($ern, $nom, $ape)
{
$this->ern = $ern;
$this->nombre = $nombre;
$this->apellido = $ape;
}
public function getNombre() {
return $this->nombre;
}
}
Class Reporte {
private $ern;
public function getDatosAlumno( $registro) { // en teoria retorna un objeto Alumno
$this->ern = $registro;
require_once("config.php"); // crea una var $con
$sqlCommand = "SELECT nombre, apellidos FROM alumno ".
"WHERE rne = '$registro' AND estado = 'A';"; $resultado = odbc_exec($con, $sqlCommand);
if (odbc_num_rows($resultado) == 0)
{
die("No hay alumno con ese Registro!");
}
else
{
$nom = odbc_result($resultado, "nombre");
$ape = odbc_result($resultado, "apellidos");
$alum = new Alumno($registro, $nom, $ape);
echo $alum-->getNombre(); // NO MUESTRA NADA
odbc_free_result($resultado);
return $alum;
}
}
}