Function in PHP returning query in oracle database

-1

I'm trying to create a function in php that brings information from my Oracle database, but the function does not return any value. This function is meant to return some user data.

The function is as follows:

<?php 
function fn_valida_permissao() {
    include ("../../DataBase/conexao.php");

    $chamado_query = "SELECT pu.idusuario IDUSUARIO
                       FROM usuario u
                      WHERE u.idusuario = upper('usuario_de_acesso')";

    $chamado = oci_parse($ora_conexao, $chamado_query);
    oci_execute($chamado);

    while($v_pagina=oci_fetch($chamado)) {
        return $v_pagina = oci_result($chamado, 'IDUSUARIO');
    }
}
?>

Would anyone have any suggestions on how to solve?

    
asked by anonymous 04.02.2016 / 19:14

1 answer

2

First, either you did not copy right, or you can see the SQL execution face error. You set FROM to alias u , but you are trying to return pu.idusuario

Second, you do not need a while if you know you're only going to return a record or want to show only one record. Once you run the first return it will exit the function.

while($v_pagina=oci_fetch($chamado)) {

    return $v_pagina = oci_result($chamado, 'IDUSUARIO');

}
    
04.02.2016 / 19:23