I need to obtain the id of the student with his rout (identification number) which I achieve in the query that I do in PDO the problem in which an array returns and not an int.
Then I was in doubt transform the value obtained in an integer or change the query to get an integer, as I understand always returns an array.
And how can I do it?
Querry
public function alumnos_id($rut){
try {
$result = array();
$sql = "SELECT alu_id FROM alumno WHERE alu_rut='$rut'";
$stm = $this->pdo->prepare($sql);
$stm->execute();
foreach ($stm->fetchAll(PDO::FETCH_OBJ) as $r) {
$alm = array(
'alu_id' => $r->alu_id
);
$result[] = $alm;
}
return $result;
} catch (Exception $e) {
echo $e;
}
}
PHP
require_once('funciones/web_services/alumnos_ws.php');
$alumnos_obj = new alumnos_ws();
$alumnos_id = $alumnos_obj->alumnos_id($rut_alumno);
echo $alumnos_id;
This returns to me on the screen a word "Array".